Call child method from parent

前端 未结 16 2341
长发绾君心
长发绾君心 2020-11-21 22:23

I have two components.

  1. Parent component
  2. Child component

I was trying to call child\'s method from Parent, I tried this way but couldn\

16条回答
  •  Happy的楠姐
    2020-11-21 23:14

    I'm using useEffect hook to overcome the headache of doing all this so now I pass a variable down to child like this:

    
     
    
    useEffect(() => callTheFunctionToBeCalled(value) , [value]);
    

提交回复
热议问题