Imagine the function of a component below:
handleInputChange(e) { // let val = e.target.value; - if I uncomment this, it works. // Update text box value this.setState(function (prevState, props) { return { searchValue: e.target.value, } }) }
and a text field that is displayed by the child component of the above component and gets handleInputChange as props :
<input type="text" onChange={that.props.handleInputChange} value={that.props.searchValue} />
When I type something in a text box, I get an error that Cannot read property 'value' of null .
If I uncomment the first line inside the handleInputChange function, where I store the value of the text field inside the val variable, this works well. Ideas why?
source share