About the rendering problem of react component

there are two child components in a parent component, which are component A, component B. Component An is the name of a list of data, and component B is a data form formed by a single piece of data of component A. how to make component A re-render after modifying the data saved in component B, so that the data of component A can be updated again?

Mar.04,2021

this is mainly a problem of communication between react sibling components. If the project is complicated, I think you can use redux to manage the data, and you can do so if you don't want to use redux,.

you can define a method in the parent component of AB and pass it to component B. For example, ask getLatestData, to modify and save the data in B and pass the updated data as a parameter to the getLatestData method. The parent component will get the updated data in the place defined by the getLatestData method, and component A like setState, will also re-render.


parent component? The communication mode of sub-components to solve your problem Demo

or use the third-party state management library (redux, mobx.)

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-1be9cc4-319bd.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-1be9cc4-319bd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?