Using useEffect to add an item to a list property in an array of objects
Imagine the following situation: I have a registration flow in which some parts of this registration are saved in the session storage to be sent at the end of the flow for an API request. On one of these screens, I select some information and, to add the cards to this list of companies created, I open a modal component and save this information set in the modal in the session to retrieve it on the original screen and include it in the list. However, since this screen has already been loaded, the useeffect has no effect and if I pass the original list as a parameter, it enters an infinite loop.
How can I solve this?
Using useEffect to add an item to a list property in an array of objects
Imagine the following situation: I have a registration flow in which some parts of this registration are saved in the session storage to be sent at the end of the flow for an API request. On one of these screens, I select some information and, to add the cards to this list of companies created, I open a modal component and save this information set in the modal in the session to retrieve it on the original screen and include it in the list. However, since this screen has already been loaded, the useeffect has no effect and if I pass the original list as a parameter, it enters an infinite loop.
How can I solve this?