CreateResource does not update as expected
I'm new to Solid, please forgive me if that is a total dummy question.
I'm using solid router and I have this code:
According to the docs,
useParams
"retrieves a reactive object containing the current route path paramteres as defined in the Route".
I'd like to understand why version A does not cause <SomeDataComponent>
to update when the route changes, but version B does.2 Replies
You're right about useParams, the problem is createResource. From the docs:
Version A just retrieves the value of id once and passes it to createResource - remember that components in solid only run once, so that
params.id
access only runs once.
Version B provides a signal that the createResource is able to track, since accessing params.id
happens inside the resource rather than outside itah, that makes complete sense, thank you @Brendonovich!