Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No SSR support (Remix): React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. #640

Open
RabeeAbuBaker opened this issue Mar 12, 2024 · 2 comments

Comments

@RabeeAbuBaker
Copy link

I have tried to use CodeMirror with Remix but it doesn't work and breaks instantly.

Here's a minimal reproduction link on codesandbox https://codesandbox.io/p/devbox/twilight-voice-33kd6j

Error:

Warning: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.
image
@RabeeAbuBaker RabeeAbuBaker changed the title Doesn't work with Remix: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. No SSR support (Remix): React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. Mar 12, 2024
@quangIle
Copy link

@RabeeAbuBaker Hi

You can try my work around until react-codemirror support Remix SSR:

import { ClientOnly } from 'remix-utils/client-only'

...

<ClientOnly>
  {() => (
    <CodeMirror extensions={[python()]} value={codeValue} onChange={(value) => setCodeValue(value)} />
  )}
</ClientOnly>

Reference:
https://github.com/sergiodxa/remix-utils?tab=readme-ov-file#clientonly

@RabeeAbuBaker
Copy link
Author

@RabeeAbuBaker Hi

You can try my work around until react-codemirror support Remix SSR:

import { ClientOnly } from 'remix-utils/client-only'

...

<ClientOnly>
  {() => (
    <CodeMirror extensions={[python()]} value={codeValue} onChange={(value) => setCodeValue(value)} />
  )}
</ClientOnly>

Reference: https://github.com/sergiodxa/remix-utils?tab=readme-ov-file#clientonly

Thanks @quangIle!
I have already used the above workaround and it's working fine, also there's another way to do it https://remix.run/docs/en/main/guides/migrating-react-router-app#client-only-components

But I'm wondering if this issue should still be open or get closed as the solutions are considered a "workaround".
I'll leave this to the admins to decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants