You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this was reported in a Slack chat, not reproducible for me, normal web-apps work because of a race-condition
expected that NextJS / remix stacks also produce the issue, it was reported with some custom built SSR
Current Behavior
The schemas are loaded on client-side but the hooks do no longer process the state updates correctly, thus always displaying Loading....
Reloading the page (when using localStorage cache) renders the schema as expected.
Expected Behavior
The schema loading should work on both sides, even when not "loading & injecting" on server, the schema should be loaded directly in client-side and rendered directly.
Each schema must only be loaded once - even when referenced multiple times in the same root-schema.
Optiomal solution would offer an option, that schemas are pre-loaded on server and no further loading in client is required.
Solution
The general problem is how useSchemaRef tries to load schemas, this currently only works because of some multiple renderings in client-side - but I expect (as far as I understand SSR) that the useRef/useMemo is re-hydrated with the latest values from server, thus it does not correctly process the actual state-reflow.
With some better state-listening inside useSchemaRef / somehow connecting the promise may allow to solve it.
the loadSchema in useSchemaRef is not using a promise
the loadSchema from UIApiProvider should actually work correctly
the loadSchema from useSchemaNetworkRef does "drop the Promise"
Returning a promise in useSchemaNetworkRef makes it possible to introduce a correct state-listening / refresh inside useSchemaRef.
It most likely will still "not load the schema on server", but it should work correctly in browser "loading schemas once after initial render".
To allow preloading from server, it may need some Supense compatible info - or something else. This would be the optimal solution, which may need to wait till v0.5.x.
Your Environment
Tech
Version
UI-Schema
v0.4.5
The text was updated successfully, but these errors were encountered:
Current Behavior
The schemas are loaded on client-side but the hooks do no longer process the state updates correctly, thus always displaying
Loading...
.Reloading the page (when using
localStorage
cache) renders the schema as expected.Expected Behavior
The schema loading should work on both sides, even when not "loading & injecting" on server, the schema should be loaded directly in client-side and rendered directly.
Each schema must only be loaded once - even when referenced multiple times in the same root-schema.
Optiomal solution would offer an option, that schemas are pre-loaded on server and no further loading in client is required.
Solution
The general problem is how
useSchemaRef
tries to load schemas, this currently only works because of some multiple renderings in client-side - but I expect (as far as I understand SSR) that theuseRef
/useMemo
is re-hydrated with the latest values from server, thus it does not correctly process the actual state-reflow.With some better state-listening inside
useSchemaRef
/ somehow connecting the promise may allow to solve it.loadSchema
inuseSchemaRef
is not using a promiseloadSchema
fromUIApiProvider
should actually work correctlyloadSchema
fromuseSchemaNetworkRef
does "drop the Promise"Returning a promise in
useSchemaNetworkRef
makes it possible to introduce a correct state-listening / refresh insideuseSchemaRef
.It most likely will still "not load the schema on server", but it should work correctly in browser "loading schemas once after initial render".
To allow preloading from server, it may need some Supense compatible info - or something else. This would be the optimal solution, which may need to wait till
v0.5.x
.Your Environment
The text was updated successfully, but these errors were encountered: