Does createAsync cause double renders on the server i.e an extra render after data becomes available
Was observing from the logs
4 Replies
By default
createAsync
serialises the promise and passes it over the wire. This means that it can start fetching on the server and immediately start streaming the rest of the application. Then once the fetch is resolved it streams the result in and lifts all the related suspense-boundaries.
If you don't want to send the application before the createAsync
is resolved you can set its deferStream
-option.deferStream: true/false doesn't have any different - both the cases, the components runs twice.
I haven't set deferStream.
This is what I understand is happening. Correct me if I am wrong.
Server does a render of the component when client requests for it the first time and streams whatever HTML it has over the wire.
Now when async resolves on the server side and again the server does render of the component.
A you mean re-rendering as in the component literally re-runs. That is very unusual for solidjs, so i think there must be something else going on.
no, that second render shouldn't happen.
Is the function you're passing to
createAsync
wrapped in a query()
?
Query will cache/deduplicate the request, otherwise I can see the request firing more than once, specially in Dev