R
Reactiflux

devTej – 15-10 Oct 8

devTej – 15-10 Oct 8

DdevTej🧑💻10/8/2022
I read react 18 documentation, that component will render twice for future features. This feature will give React better performance out-of-the-box, but requires components to be resilient to effects being mounted and destroyed multiple times as per them when the user switches the tab and comes back it will persist the previous state, My question is even if it persists the state, it will still run the useEffect which may make API calls and what is the use of unmounting and remounting the component in current release
RRhys10/8/2022
From my understanding, the main reason for it running twice is people were putting things in use state that shouldn’t be in use state, I.e api calls so it was changed to discourage that Take a look at react query: https://tanstack.com/query/v4 The basic concept is instead of using useEffect for API calls, you should write your API call as a hook as it gives you better control of the data flow @devTej
UUUnknown User10/9/2022
2 Messages Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

devTej – 15-10 Oct 8

Join Server