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 issueI 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"]
+ },
}
- react-native-svg 9.13.3
- react-native-svg-transformer 0.14.3
- SDK: 36 Documentation: https://docs.expo.io/versions/latest/sdk/svg/
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:12 (3 by maintainers)
Top 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 >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’m doing this for now to make it work,
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.