How do you keep reactivity?
I'm trying to organize my code but I lose the reactivity on the way...
When the
searchParams.id value is set from undefined to a correct string value, I would expect the query to be executed and the effect to be triggered. It is not.
If I uncomment the createQuery section instead of using getProgram, it works.
6 Replies
make
getProgram take an Accessor<string | undefined> rather than just a ?string
that way the searchParams store is read inside the createQuery args rather than in the component body (which only runs once)hhm
the commented out version you have works because
searchParams is being read inside the createQuery argArgument of type 'string | undefined' is not assignable to parameter of type 'Accessor<string | undefined>'.
Type 'undefined' is not assignable to type 'Accessor<string | undefined>'.
you'll need to pass an accessor to
getProgram too like () => searchParams.idare you suggestint to pass the searchParams instead of searchParams.id?
I see\
yup working
still not used to these "tricks", thank you