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.

work on the web, Warning: </static/media/splashScreen.0f923900.svg /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

See original GitHub issue

I have installed in my project expo install react-native-svg.

I have exported the svg as a component by doing:

import Logo from './logo.svg';
export default Logo;

It can render on native but fail on the web.

bundle.js:69367 Warning: </static/media/splashScreen.0f923900.svg /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.

I have followed that configuration https://github.com/react-native-community/react-native-svg#use-with-svg-files

My metro.config.js is equal:

const { getDefaultConfig } = require('metro-config');

module.exports = (async () => {
  const {
    resolver: { sourceExts, assetExts },
  } = await getDefaultConfig();
  return {
    transformer: {
      babelTransformerPath: require.resolve('react-native-svg-transformer'),
    },
    resolver: {
      assetExts: assetExts.filter(ext => ext !== 'svg'),
      sourceExts: [...sourceExts, 'svg'],
    },
  };
})();

My app.json got added

{
+    "packagerOpts": {
+      "config": "metro.config.js",
+      "sourceExts": ["js", "jsx", "ts", "tsx", "svg"]
+    },
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
pyrosshcommented, May 24, 2020

I’m doing this for now to make it work,

const Icon = ({ children }) => {
  if (Platform.OS === 'web') {
    return <img src={children.type} {...children.props} />;
  }
  return children;
};

 <Icon>
     <ArrowBackIcon width={32} height={32} />
</Icon>
1reaction
joranbcommented, Mar 23, 2022

Would just mention my comment here: https://github.com/expo/expo/issues/6660#issuecomment-1076338873

There is someone who has fixed this issue in this unpublished package: https://github.com/HolovisSoftwareDev/react-native-svg-transformer-fix-expo

See my comment for an example.

I can confirm it then works with latest Expo, react-native-svg and react-native-svg-transfomer on web, iOS and Android without the need to run Platform.OS checks when importing static svg files.

It is however not clear to me if this issue fix has to be implemented on the Expo side or in react-native-svg-transformer, but maybe you could take a look when you have time @kristerkari . This issue has been a huge pain for me, used several days troubleshooting, finally found a solution that works. But it would be nice to get rid of the unpublished fix package and just use react-native-svg and react-native-svg-transformer when using Expo, but the bug has to be fixed first.

Read more comments on GitHub >

github_iconTop Results From Across the Web

importing .svg does not work on the web, Warning: </static/ ...
0f923900.svg /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
Read more >
SVG with React via svgr failing
BkZWZhdWx0IFN2Z0NvbXBvbmVudDs= /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.
Read more >
Jest
Transforms SVG into React Components. ... Configure Jest to work properly with SVGR. 1. Create a mock file. Create a mock file __mocks__/svg.js...
Read more >
How to use SVG Icons as React Components
Today I want to give you a straightforward approach on how to use SVG icons as React components for your next React application....
Read more >
[Solved]-Warning: <Link /> is using incorrect casing. ...
Coding example for the question Warning: is using incorrect casing. Use PascalCase for React components-Reactjs.
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