react_on_rails
react_on_rails copied to clipboard
unable to use React suspense with react_on_rails gem
I'm trying to use the experimental version of react to use suspense for data fetching etc…
i installed the experimental version of react via npm (had to use --force). (not sure if the dependency issue i had was react_on_rails related)
Also, part of the install process says to change this:
ReactDOM.render(
<React.StrictMode>
</React.StrictMode>,
document.getElementById(“root”)
);
to this:
ReactDOM.unstable_createRoot(document.getElementById(“root”)).render(
<React.StrictMode>
</React.StrictMode>
);
However, with react on rails it works different.
How can i enable react experimental mode to be able to use React.suspense
Thanks for any help…
You can make a PR to try allowing for another option here:
https://github.com/shakacode/react_on_rails/blob/master/node_package/src/clientStartup.ts#L171
if (isServerRenderResult(reactElementOrRouterResult)) {
throw new Error(`\
You returned a server side type of react-router error: ${JSON.stringify(reactElementOrRouterResult)}
You should return a React.Component always for the client side entry point.`);
} else if (shouldHydrate) {
ReactDOM.hydrate(reactElementOrRouterResult as ReactElement, domNode);
} else {
ReactDOM.render(reactElementOrRouterResult as ReactElement, domNode);
}
Once this feature is non-experimental, I plan to support this.
@ziploker and others, PRs welcome!