Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
See original GitHub issuei used Expo, here my package.json:
"expo": "~40.0.0",
"react": "16.13.1",
"react-native-svg": "12.1.0",
"react-native-svg-transformer": "^0.14.3"
i just followed the tutorial but i got this.
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
here’s my metro.config.js :
const { getDefaultConfig } = require('@expo/metro-config');
module.exports = (async () => {
const {
resolver: { sourceExts, assetExts }
} = await getDefaultConfig(__dirname);
return {
transformer: {
babelTransformerPath: require.resolve('react-native-svg-transformer')
},
resolver: {
assetExts: assetExts.filter((ext) => ext !== 'svg'),
sourceExts: [...sourceExts, 'svg']
}
};
})();
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
Invariant Violation: Element type is invalid: expected a string ...
This error can rise if you try to import a non-existent component. Make sure you have no typo and that the component indeed...
Read more >(React) Element type is invalid, expected a string (for built in ...
To solve the error "Element type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got",...
Read more >Element type is invalid: expected a string (for built ... - GitHub
The app breaks and gives this error message: Element type is invalid: expected a string (for built-in components) or a class/function (for ......
Read more >Element type is invalid: expected a string (for built-in ... - Reddit
Getting Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: ...
Read more >Element type is invalid: expected a string (for ... - OneCompiler
Element type is invalid : expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue, and here is how I resolve it:
react-native start --reset-cache
watchman watch-del-all && rm -rf /tmp/metro-bundler-cache-* && rm -rf /tmp/haste-map-react-native-packager-*
Hope this can help!
Having the same issue and configured as described. Of course restarted everything. The import result will always be an empty object.
Reverting to
0.20.0
resolves the issue.