Async component local state not hydrated
bost-h opened this issue · 2 comments
Hello,
First, thank you for your great work ! I daily use few of your packages (async-boostrapper, react-universally etc)
I have an issue with react-async-component with SSR, which does not rehydrate components local states. Is this a feature this package is supposed to offer, or did I misunderstood allowing client side state rehydration, avoiding React checksum errors.
?
I have no simple example to submit (SSR+CodeSplit is not simple :p) but this can be reproduced with react-universally in a few steps :
- Clone react-universally (master)
- Edit
shared/components/DemoApp/AsyncCounterRoute/CounterRoute.js
- Add a componentWillMount() which modify state (not predictable) like :
componentWillMount() {
this.setState({counter: Math.random()});
}
--> State is not rehydrated, react checksum errors appears etc.
Thank you !
Hey @bost-h
Thanks! Glad to hear you are making good use of my packages. I love to hear this.
Yeah, it's not expected to keep state, that is a separate issue. If you are configuring state on the server and wish to transport that to the client you may need to introduce another library for this case. I have another package actually (lol) called react-jobs
.
Have a look, it could help with your requirements.
Understood !
Thank you again, I close this