Replies: 1 comment 1 reply
-
I think if you use the React v18 it will work |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, lazy components can only be achieved client-side due to the nature of
React.lazy
in React 17. This will change in React 18. Issue: #129Example:
Attempting to use
lazy
in a server-rendered component will throw the expected error:Rendering different versions of components at the server is crucial for product teams to use with feature flags or A/B testing tools without requiring changing code. Being limited by doing this at the client-side takes away from Remix's biggest strengths.
Currently, the only workaround is to create multiple routes and change the URL that is sent to
RemixServer
without actually changing the URL displayed to the user. E.g:With the routes:
/testing
index.jsx
testing.a.jsx
testing.b.jsx
Rendering
/testing?version=a
will render internally/testing/a
and/testing/b
respectively, while maintaining the original/testing
path.It's a trivial example, but in practice, this would be using ENV variables or the response from an API.
While doable, this is by no means the desired solution.
Next provide this with
next/dynamic
through their own version of react-loadableLoadable Components is another possible solution.
What's your recommendation?
Beta Was this translation helpful? Give feedback.
All reactions