What is wrong with Math.random create Signal
This code:
produces different values on interface and in createEffect log, what is going on?
5 Replies
This should give some insight 😉
I see isServer and isClient executes twice, but what is the best way to fix this?
The inital value of the signal is create twice: Once on the server for SSR and then again on the client to make stuff reactive. And math.random() creates different values obviously.
So to get around that you could
a. disable SSR in the app config if you don't need it ... or ...
b. render the component clientOnly
A: would be like
thanks for the very detailed answer.
One more thing, I have this for creating a session password:
Where should I put this so it is set once the server starts and never changes on every request, because when I put this at the top level of app.tsx, it changes with every request.
Not possible.
That’s why we use env variables.