jSutcliffe90 jSutcliffe90 - 8 days ago 4
Javascript Question

React container not binding correctly

I'm currently working on a search bar and the value of the input is not displaying in the search bar. When I log the value in the console it only displays one character at a time

enter image description here

I'm assuming that the way that I have set up my state and term is incorrect and rewriting the state everytime it fires, rather than updating it?

enter image description here

Cheers

Answer

You have an extra = sign in your setState function.

this.setState is a function, not a variable. You have to pass argument into it, not assign a new value.

Change it into:

this.setState({ term: event.target.value })