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

using an object spread followed by a key breaks react #2534

Closed
mcansh opened this issue Sep 8, 2022 · 0 comments
Closed

using an object spread followed by a key breaks react #2534

mcansh opened this issue Sep 8, 2022 · 0 comments

Comments

@mcansh
Copy link

mcansh commented Sep 8, 2022

  1. using the automatic jsx runtime
  2. use a {...spread} followed by a key={blah}
  3. having a package that ends with "react" (@remix-run/react) in this case

causes import_react to be redeclared and pointing to both "react" and "@remix-run/react" which causes react to throw due to the lovely Element type is invalid error

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.

sample code: https://github.com/mcansh/remix-borked

the following is a sample of the build output:

var import_stream = require("stream"), import_node = require("@remix-run/node"), import_react = require("@remix-run/react"), import_server = require("react-dom/server"), import_jsx_dev_runtime = require("react/jsx-dev-runtime"), ABORT_DELAY = 5e3;

// later on in the same file...

var import_react3 = require("@remix-run/react"), import_jsx_dev_runtime = require("react/jsx-dev-runtime"), import_react = require("react")

for good measure, here is our current esbuild config for our server builds: https://github.com/remix-run/remix/blob/7730e653db3d6b531cfffd835d5f8b9bf6b22053/packages/remix-dev/compiler.ts#L428-L475

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

1 participant