Call child component method from parent component in reactjs

后端 未结 5 891
[愿得一人]
[愿得一人] 2021-02-10 01:41

I have requirement to call child component method from parent component in reactjs. I have tried using refs but not able to do it. Can anyone please suggest any solution. Than

5条回答
  •  南笙
    南笙 (楼主)
    2021-02-10 01:58

    You can pass registerCallback props to your child and call it from componentDidMount and pass reference to your child component method, then you can call it method at anytime

提交回复
热议问题