Warning: React.jsx: 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. #12656
Replies: 9 comments 13 replies
-
I was getting the same error while trying to run "npm test" when imported component for testing wasn't imported right. in Header-component I say "export default Header" |
Beta Was this translation helpful? Give feedback.
-
In my case, exporting it as a default was the problem. |
Beta Was this translation helpful? Give feedback.
-
In my case, I close the app and open it again |
Beta Was this translation helpful? Give feedback.
-
In my case, I was importing from "...../button" instead of "...../Button" |
Beta Was this translation helpful? Give feedback.
-
Ran into this today and worked for several hours... Due to some weird merge issue, I was exporting some components more than once in an index file, which caused the issue |
Beta Was this translation helpful? Give feedback.
-
In my case, I was exporting and importing a react component and type from the same file which was throwing this error. Changed
to
|
Beta Was this translation helpful? Give feedback.
-
In my case i used |
Beta Was this translation helpful? Give feedback.
-
In my case i created components with string FC in the end name of component... Only rename and load project with successfuly again... |
Beta Was this translation helpful? Give feedback.
-
In my case, it turns out I had cyclic dependencies I didn't know about. My app uses webpack which doesn't seem to mind them, but jest executes everything synchronously so it does. Before:
After:
This probably isn't the best solution, but it helped me confirm that cyclic dependencies were my problem :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
package.json
App.tsx
Home.tsx
yarn start
The first rendering is normalWhen I try again home When the < Checkbox / > component is added to the TSX render function, an error is reported as follows:
Ask for help TKS
Beta Was this translation helpful? Give feedback.
All reactions