Am I doing something wrong with the loader function?
Hello everyone! 👋
I use my route's loader function to perform asynchronous processing that builds and returns a map (openlayers) and synchronous processing that returns what I call a graph (it's my own business object) that I use in my React component to pass as props to other components. I use the map in a useEffect to display it in the first rendering (setTarget).
I'm asking myself a few questions. Normally, I'd want to perform a map.dispose() in the cleanUp function of the useEffect(), but due to the double execution of the effect because of react's strict mode, it doesn't render any map when I'm not in production, and I'd like to continue using strict mode.
Also, if I change the page, will my map be automatically cleaned(if you have a link to the doc on memory management with the router, I'd love one)?
The loader gives me great code readability and simplifies things a lot, but am I really allowed to use it like this, am I doing something wrong?
Thank you in advance for your time and help.

0 Replies