0

I have an svg file inside assets / shape_dividers that I want to access. But the problem is that I want to access from Welcome.js . I was searching in some other posts and they say to install babel-plugin-module-resolver but I still have problems.

.babelrc File

{
  "plugins": [
    [ "module-resolver", { "root": ["./"] } ] 
  ]
}

Welcome.js

import Wave from 'assets/shape_dividers/wave';

Directory:

enter image description here

Reis
  • 101
  • 2
  • 7
  • Does this answer your question? [How to show SVG file on React Native?](https://stackoverflow.com/questions/38830568/how-to-show-svg-file-on-react-native) – Kai Apr 28 '21 at 18:29
  • @Kai I am answering about acessing an file of assets in a script on views – Reis Apr 28 '21 at 18:31
  • I understand, but the way you are trying to import that SVG is not going to work – Kai Apr 28 '21 at 18:34
  • @Kai https://blog.usejournal.com/how-to-use-svg-in-react-native-e581eca59534 – Reis Apr 28 '21 at 18:35
  • @Kai I will take a look at this post, but how can I acess the assets folder? – Reis Apr 28 '21 at 18:43
  • It looks like your filepath needs to be `'../assets/shape_dividers/wave.svg'` – Kai Apr 28 '21 at 18:51
  • @Kai Error 500 https://pastebin.com/K94JpEJj – Reis Apr 28 '21 at 18:55
  • I suspect your metro.config.js is not set up correctly, you'll want to verify that it matches the example – Kai Apr 28 '21 at 19:07
  • I copy and paste the example again to be exactly the same thing, but the error continue except when I remove import – Reis Apr 28 '21 at 19:20
  • @Kai problem solved. I was using shape not shapes – Reis Apr 28 '21 at 20:43

1 Answers1

0

Problem Solved.

1- I uses .. to back one folder

  1. I was using shape rather than shapes

Final Code:

  import Wave from '../assets/shapes_dividers/wave.svg';
Reis
  • 101
  • 2
  • 7