`createServerData` with `fetch` is returning `undefined` in `createEffect`
Here's a minimal example.
Note that the
fetch
is required to cause the issue and that I can "fix" the issue by calling the signal in the outer scope. I'm on solid-start 0.2.23.
Is this expected behavior?7 Replies
I think it's because effects are not run on the server, therefore, as far as solid is concerned, the value isn't used and doesn't need to be computed
Although my understanding is also quite limited
It should still work if you place the signal in the JSX though
it's unclear to me why
fetch
causes this behavior 😅yeah, does the serverData function run at all with the fetch within it?
Yes, the Fetch runs, even though
myServerData
returns undefined
I think the signal getter needs to be invoked for it to be tracked, maybe with a synchronous function the data is returned immediately, but adding fetch could mean that the synchronous code continues - sending the rendered page to the client without this value, and the first time that the getter is invoked is on the client
because I think in javascript even functions marked as async execute synchronously until an await is encountered
This is only my best guess
Someone better versed in solid will probably give a much better explanation
Related question https://discord.com/channels/722131463138705510/1081496033042911372
thanks