How to reload a component in solidjs (a route or a specific component) (I'm using solidjs/router)
I need to be able to reload a component clicking a button or reload the whole route page clicking another button. I want the same functionality like doing a window.location.reload but more specific with a router page or a component.
6 Replies
Have you figured it out? I'm also curious 👀
Nop 😅
I'm not sure why you want to reload the whole page but maybe you could use createEffect to achieve your goal. Surely something changes when you go to the component? Maybe the path params? You could use a createEffect to watch for those changing
I wanted to reaload a graph calling a get and all the functions that are called transforming the get on the OnMount
I think the easiest way is to reload the component, to mount it again to not repeat code
This is from the new solidJS docs: "Component functions are only ever called once before disappearing. Components exist to organize your code, not deal with updates or re-renders."
https://docs.solidjs.com/guides/foundations/thinking-solid
Even with that there are cases when the simplest and the more clean way to solve some things is to re-render the whole component, to don't complicate the code excessively.