简体   繁体   中英

One component affecting another in reactjs

Every url loads three main components: Left panel, center and right panel. In right panel, we have a button which returns a sub-component CreateForm inside the right panel. Left panel contains links which returns individual sub-component to left panel.

Here, the problem is every sub-component of the left panel changes url and thus loads three main components; so if current state of form is open on the right panel and if we select any links in the left panel sub-component, we get the right panel reloaded again so we cannot stay to form.

How can I solve that?

We had use useEffect, localstorage for storing state of the contact form and do form component code inside rightpanel component only(without calling separate component for form on click). This worked well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM