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 width ...

See original GitHub issue

Bug

Screenshot_1563544674

React native info output:

System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
    Memory: 1.40 GB / 11.60 GB
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 10.16.0 - /usr/bin/node
    Yarn: 1.17.3 - /usr/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  IDEs:
    Android Studio: 3.3 AI-182.5107.16.33.5314842
  npmPackages:
    react: 16.8.6 => 16.8.6 
    react-native: ^0.60.4 => 0.60.4

Library version: 9.5.3

Steps To Reproduce

Before: yarn add react-native-svg yarn add react-native-svg-transformer -D

After Enable hermes yarn add babel-plugin-inline-import -D

Describe what you expected to happen:

  1. Show icons

Reproducible sample code

myComponent.js

import React from "react";
import { Platform } from "react-native";

import IconHome from "./../imgs/icon/home.svg";
export const Home = props => ( <IconHome { ...props } width={22} height={22} /> );

screen.js

import { Search, Genero, MinhasMusicas, Home } from "./../components/Icon";
<Home key={1} />

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:20 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
waleedarshadcommented, Oct 14, 2019

Same issue While running svg with transformation

package.json "react-native": "0.59.9", "react-native-svg-transformer": "^0.13.0",, "react-native-svg": "^9.9.4",

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"]
    }
 };
})();`

index.js

import { Bower } from "./bower.svg";
<Bower width={120} height={40} /> Not working???

if I use with SvgXml it works.

import { SvgXml } from "react-native-svg";
 <SvgXml width="200" height="200" xml={Bower} /> Working
Screenshot 2019-10-14 at 17 59 41
0reactions
bensonnn7commented, Aug 27, 2020

Same issue While running svg with transformation

package.json "react-native": "0.59.9", "react-native-svg-transformer": "^0.13.0",, "react-native-svg": "^9.9.4",

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"]
    }
 };
})();`

index.js

import { Bower } from "./bower.svg";
<Bower width={120} height={40} /> Not working???

if I use with SvgXml it works.

import { SvgXml } from "react-native-svg";
 <SvgXml width="200" height="200" xml={Bower} /> Working
Screenshot 2019-10-14 at 17 59 41

Hi, I have encountered the same issue, did u figure it out?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invariant Violation: View config not found for name <svg width
Actually, it seems the transformer isn't working/configured correctly. Seems you're trying to use the svg string as a component, rather than an ...
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 >
[Solved]-Invariant Violation: View config not found for name view
Coding example for the question Invariant Violation: View config not found for name view : React Native-React Native.
Read more >
Reactnativesvgtransformer Not Working with the Metro.Config ...
React Native SVG transformer allows you to import SVG files in your React ... I get an Invariant Violation which tells me to...
Read more >
react-native-svg - npm
✓ The Expo client app comes with the native code installed! Install the JavaScript with: expo install react-native-svg. See the Expo docs ...
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