2

I want to ask if there is a possible pattern to access a child state from parent. For example I have an array of childs rendered in the Parent component, but now I want to access the state of each child of the list from the Parent, I used ref but it works only with the last element.

I hope the problem is clear, thank you.

(I know I can solve it with Redux, but it is complicated because the list can change its size dynamically)

  • 1
    duplicate: https://stackoverflow.com/questions/27864951/how-to-access-childs-state-in-react – lnogueir Mar 15 '21 at 15:25
  • Short Answer: No. A child can pass its state to the parent by calling a function prop the parent passed to the child. Like `onChange` – Greg M Mar 15 '21 at 15:28

0 Answers0