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.

Invariant Violation: View config not found for name (svg content)

See original GitHub issue

My app can’t render svg file because this error code.

this is error code.

error

Exception: Invariant Violation: View config not found for name <?xml version="1.0" encoding="UTF-8" standalone="no" ?><svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 235.032 75.093" width="235.032" height="75.093"><path d="M8.828 

I’m struggling with this issue for about a day.But I couldn’t reach solution…

could you help me?? Do you have any idea of the cause and resolution.

metro.config.js

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

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

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
  plugins: [
    [
      'babel-plugin-module-resolver',
      {
        root: ['./src'],
        extensions: [
          '.ios.ts',
          '.android.ts',
          '.ts',
          '.ios.tsx',
          '.android.tsx',
          '.tsx',
          '.jsx',
          '.js',
          '.json',
          '.svg'
        ],
        alias: {
          '@navigations': './src/navigations',
          '@models': './src/models',
          '@reducks': './src/store/reducks',
          '@screens': './src/screens',
          '@apis': './src/apis',
          '@utils': './src/utils',
          '@plugins': './src/plugins',
          '@assets': './src/assets',
        },
      },
    ],
    [
      "babel-plugin-inline-import",
      {
        "extensions": [".svg"]
      }
    ]
  ],
};

the code

import Logo from '../assets/images/logo.svg';

<Logo width={50} height={50} />

I tried this code, the error not occured,but image was not rendered.

import {SvgXml} from 'react-native-svg';
<SvgXml xml={SvgXml} width={50} height={50} />

basic information

    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-svg": "^12.0.3",
    "react-native-svg-transformer": "^0.14.3",

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
tracyhyqcommented, Mar 23, 2020

@Yoshihide-Nishimoto the same to me? Have you solved the problem?

0reactions
brokrete-oleksiicommented, Jan 23, 2022

@Yoshihide-Nishimoto

 [
      "babel-plugin-inline-import",
      {
        "extensions": [".svg"]
      }
    ]

This block is the reason for the problem. Remove it from babel and will be good. I had the same error and removing helped.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: View config not found for name (svg ...
I have tried another way. Convert content of svg file to React Native Component via https://react-svgr.com/playground/?native=true&typescript= ...
Read more >
react-native: Get error, invariant violation: View config not ...
Try linking React Native SVG manually. Add the following to 'android/settings.gradle'.
Read more >
View config not found of RNSVGCircle-React Native
Coding example for the question react-native: Get error, invariant violation: View config not found of RNSVGCircle-React Native.
Read more >
React Native: View config getter callback for component must ...
You're coding a React Native App and suddenly get an unexpected error: Invariant Violation: View config getter callback for component `div` must be...
Read more >
Trouble with @types/react - Blog
The component creates a div element, but there is no such thing as a div in ... Invariant Violation: View config not found...
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