Managing state when using multiple subcomponents
P粉032649413
P粉032649413 2023-09-15 10:09:19
0
1
621

I am not a reaction expert. My problem statement is

  • I have a main component that renders multiple subcomponents in sequence to achieve specific functions
  • Now, when I save the main component, I also want to save the child component's information.

What is the correct way to handle this problem?

  1. Use callbacks in subcomponents that return subcomponent status?
  2. redux store/ useContext hook? Anything else?

It would be great if I could get some advice. Thanks in advance

P粉032649413
P粉032649413

reply all(1)
P粉493534105

Usually this is done via "raise state" , so one solution is to manage all the state in the main component (including child component state) and in the props and functions that trigger the save Pass status.

This general concept can also be applied to "grouping" state into some meaningful objects in a redux store or reactive context.

Some related questions:

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template