The problem of communication between components

problem description

the left and right modules are made up of many sub-components respectively. When you click on a sub-component on the left, the panel on the right shows different content (the content is made up of many sub-components)
[Q]: when the values in the various sub-components on the right change, how do you display the values of these changes in the corresponding sub-components on the left?

related codes

clipboard.png

what result do you expect? What is the error message actually seen?

the subcomponents on the right are public. Click on the other components on the left, and the right part may refer to some common components, so when the values in the subcomponents on the right change, how do you display these values in one of the subcomponents on the left?

I think that I need to store the value in state, but this logic has not worked out all the time. React, is still a rookie. Please give me some advice and some ideas. Thank you in advance.

Apr.01,2021

1, you can consider updating the left component state;
2 when the right component onchange is called, and you can update these states in the common parent components of the right component and the left component ;
3, Advanced: introduce redux but since the landlord is still a novice, additional learning tasks are not recommended


the component on the left and the component on the right subscribe to the same store at the same time. Change the left or right side to modify store , and store to update the left and right components.

specific implementations include parent-child transmission , redux , event bus and even localStorage can also


redux can easily implement your requirements. The way of using state father and son to transfer data will be more roundabout. It is recommended to introduce redux

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5af3a-4560d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5af3a-4560d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?