question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

i 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:open
  • Created 3 years ago
  • Reactions:7
  • Comments:7

github_iconTop GitHub Comments

12reactions
nysamnangcommented, Aug 20, 2021

I have the same issue, and here is how I resolve it:

  1. Kill the terminal
  2. Run react-native start --reset-cache
  3. Run watchman watch-del-all && rm -rf /tmp/metro-bundler-cache-* && rm -rf /tmp/haste-map-react-native-packager-*
  4. Re-run the project
  5. Done!

Hope this can help!

0reactions
shllgcommented, Jan 26, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found