#Vite `xxx.client.tsx` showing Element type is invalid

1 messages · Page 1 of 1 (latest)

severe jewel
#

I unfortunately need to use the xxx.client.tsx route option to load some third party code, and I'm getting the following error which I think may be related. Does anyone have experience with this or could it be a bug / function of how remix and vite work together? I tried both using default and named exports. Thanks in advance! 🙏

chunk-UJBO7CMO.js?v=3fa87af4:15313 Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
...
bleak raven
#

You probably have figured out by now, but using the .client extension is not enough to avoid the server to try to render that component (don't ask me why).
See this issue: https://github.com/remix-run/remix/issues/8691

You need to use the ClientOnly component from remix-utils...

GitHub

Reproduction Create a new remix project. I assume that the latest 2.6.0 remix version will be installed. (if on windows don't initialize a git repository, because it will break the setup proced...