i expect a refetch with new data when the value of "firma()" changes - but this don't work.

export function routeData({ params }) { return createServerData$( () => prisma.DP_T_Mitarbeiter.findMany({ where: { Betrieb: firma() } }), { key: () => ["DP_T_Mitarbeiter", firma()] } ); } What do i missing?
3 Replies
Martnart
Martnart2y ago
Where are you getting firma from? It's not declared in the routeData
matulla_ffm
matulla_ffmOP2y ago
It‘s stored in an signal. To be exact: it seems to do a refetch but don‘t use the actual value
Martnart
Martnart2y ago
The signal is outside of the scope of the routeData, meaning it is in a global scope? If so, I would advise against it. It is considered dangerous to have "shared state" (in SSR, functions are called and thus create their own scope. But anything global is shared across all users) If you want a dynamically updating result based on some user selection, I would probably go for an in-route resource which will refetch correctly based on a runtime value. You could also opt for a global Context instead which should be inserted in your root.tsx somewhere above your FileRoutes. With such a context you can access/manipulate a global state in routeData functions on a per-user basis.
Want results from more Discord servers?
Add your server