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 a textbox, 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 text field I get error that Cannot read property 'value' of null
.
If I uncomment the first line inside handleInputChange
function, where I store text box value inside val
variable, it works well. Ideas why?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…