Say I have a class component function like so which accesses the props
myFunction() {
console.log(this.props)
}
if this component the renders a functional component inside it and I pass it down like so:
<MyFunctionalComponent onChange={this.myFunction} />
this then breaks saying cannot read props of undefined presumably because the concept of "this" isn't in functional land
is there an easy way to fix this except for a big refactor? or passing props in as arguments rather than this.
You really answered your own question.
because you are working in a class Component, you have to use 'this.' to pass the method. What I would do is the following.
<MyFunctionalComponent onChange={() => this.myFunction()} />