4 ms·
> route change, component "mounting", data fetching... This should really be: route change -> data fetching -> rendering After the data is fetched, it should
by branko_d 4y ago
> route change, component "mounting", data fetching...
This should really be:
route change -> data fetching -> rendering
After the data is fetched, it should just be assigned to a state somewhere, and the React should, well, "react" to the state change. This may seem a bit complicated for simple cases, but keeps the execution flow explicit and "steppable" though the debugger.
We use MobX for the "react" part; I'm sure this is not the only way.
- the_gipsy 4y agoYes, but that is The Elm Architecture. React's docs guide you towards using react-query and react-router, making everything lifecycle bound and the renders impure. https://react.dev/reference/react/useEffect#what-are-good-alternatives-to-data-fetching-in-effects https://react.dev/reference/react/useEffect#what-are-good-al...