67
rated 0 times
[
69]
[
2]
/ answers: 1 / hits: 24743
/ 7 Years ago, thu, june 22, 2017, 12:00:00
Consider below function of some component:
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 an input, which is rendered by a child component of above component, and receives handleInputChange
as props
:
<input type="text" onChange={that.props.handleInputChange} value={that.props.searchValue} />
When I enter something in input I get error that Cannot read property 'value' of null
.
If I uncomment the first line inside handleInputChange
function, where I store input value inside val
variable, it works well. Ideas why?
More From » reactjs