Skip to content
Advertisement

Passing Props to grandchild React

Child:

JavaScript

Parent:

JavaScript

GrandParent Component:

JavaScript

I simply want to pass the method handleButtonChange() from grandParent all the way to child (which is a button), as the button is clicked it triggers the click event which fires up this function making changes in grandparent component(i.e. setting button state) where am i wrong at or this approach is completely wrong I am really new to react. i am just want to set state in grandParent via child click event. i keep getting this error TypeError: this.props.handleButtonChange is not a function would appreciate any help

Advertisement

Answer

You have a typo in your top component

It should be

JavaScript

and not

JavaScript

Alternatively you can declare your method like this

JavaScript

without using bind at all.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement