Call child component method from parent component in reactjs

后端 未结 5 902
[愿得一人]
[愿得一人] 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 02:17

    Don't :)

    Hoist the function to the parent and pass data down as props. You can pass the same function down, in case the child needs to call it also.

    https://facebook.github.io/react/docs/lifting-state-up.html

提交回复
热议问题