-
Notifications
You must be signed in to change notification settings - Fork 2
Error: Invariant failed: .create
cannot be used on server side with caching enabled
#34
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Code example of the |
Stack trace would also be helpful. |
Repro: https://github.com/laggingreflex/repro-react-async-ssr Here's the Stack trace:
|
Thanks for the repro. There's two problems here. Firstly, Second is that, because The solution is to use Try substituting this into your example: function Suspended( props ) {
const [id, setId] = useState( 0 );
const resource = Resource.use( { id } );
const [startTransition, isPending] = useTransition( { timeoutMs: 3000 } );
const update = () => {
startTransition(() => {
resource.dispose();
setId( id => id + 1 );
});
};
return h( Suspense, { fallback: 'Loading' }, h( App, { resource, update, isPending, ...props } ) );
} I'm not at all familiar with Also, this library is targeted at React's stable public releases - I don't know if this package will work at all with the the experimental branch, concurrent rendering etc. As mentioned in the docs for this package, SSR is not stable in React > 16.9.x (unfortunately React made some changes in 16.10.0 which completely broke SSR + Suspense). I'd be interested in hearing if it does work, so please let me know. |
NB I see in your example you have lines commented out where the resource's |
I did try Here's what The main thing to note is that when you click "Next", it loads the profile in background, and then immediately switches to it without the "Loading Profile..." text (not to be confused with the "Loading.." text on the disabled button). I modified the above example using react-lazy-data's And here you can see that it momentarily does flash the "Loading Profile..." text, below the button, even though And it's only then that I decided to use the So that's my conundrum. Using Would love if you have any solution for this? |
I think this may be related to incompatibility between Closing since this has gone off topic. Thanks for the response! |
Found a possible solution: calling
https://codesandbox.io/s/great-heisenberg-nthzv @overlookmotel Is that OK to do? |
Getting this error on server-side when using
.create
Does that mean I should disable serialization when on server? That doesn't seem to work either, it gives another error:
The text was updated successfully, but these errors were encountered: