Answer the question
In order to leave comments, you need to log in
How not to lose context in React when passing a function to props?
From the comp1 component I pass a bunch of parameters to the comp2 component, and from it to the comp3 component. Here I have a stupid component that I want to pass some of this data to.
But in comp3 I can't properly pass the function to the stupid component -- the this is lost.
comp3 looks like this:
function comp3({
items,
action,
actionSceneNum
}) {
return(
<Comp4
handleRepeatActionClick: () => {
actionSceneNum(false)
},
/>
)}
this.setState({ opened: isOpened })
handleRepeatActionClick: () => {
actionSceneNum(false)
},
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question