S
SolidJS•16mo ago
akerbeltz

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
ai6
ai6•16mo ago
Have you figured it out? I'm also curious 👀
akerbeltz
akerbeltzOP•16mo ago
Nop 😅
Grahf
Grahf•16mo ago
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
akerbeltz
akerbeltzOP•16mo ago
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
Grahf
Grahf•16mo ago
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
akerbeltz
akerbeltzOP•16mo ago
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.
Want results from more Discord servers?
Add your server