solid-router not updating when going the same page but with different parameters
o/ so i have this in
/routines/[id].tsx:
for some reason switching between two different pages of the same route (e.g. /id/1 and /id/2) doesn't change the routine and setRoutine. am i doing something wrong? (notice the address changing but the content remaining)6 Replies
note:
storage is a store that itself contains a routines array, routine is an object that contains a string "id"You'll want to access
params.id in an effect and update the store within that effect
Otherwise it won't be reactivei did that, but i started getting weird behavior where if i click on the first routine, then the second routine, the first routine becomes a clone of the second routine
i tried a hacky way, changed the
the updated code that works:
there are probably many things wrong with that, but i'd hope there's a better approach
routine and setRoutine to be a let instead of const, then update their values directly inside an effect. this made switching pages not affect the data at all. so i went further and put the Store<Routine> and SetStoreFunction<Routine> inside a signal, and that worked
the updated code that works:
there are probably many things wrong with that, but i'd hope there's a better approachYou probably want to make a copy of the routine data when you set it
yeah sadly thoughg routines contain lots of functions and things unsupported by structured cloning
but what's
on?on is a way to explicitly set the dependencies for the effect.
https://www.solidjs.com/docs/latest/api#on
if it's not too nested, you could perhaps just {...routineData}