Cannot Read Property 'props' Of Null - Reactjs
Basically i want to call a function from parent component in child component. That function will change parent component's state. I have created a handler in parent and passed it
Solution 1:
In child component you need to bind context properly:
<button onClick={this.handleClick.bind(this)}>Continue</button>
or better to bind in constructor:
this.handleClick = this.handleClick.bind(this)
// => <button onClick={this.handleClick}>Continue</button>
or call it as a method:
<buttononClick={() => this.handleClick()}>Continue</button>
Finally, you need to actually call your callback:
handleClick() {
this.props.handler();
// note ------^
}
Post a Comment for "Cannot Read Property 'props' Of Null - Reactjs"