My folder structure :
-assets
--images
---potrait.png
-src
--file.js
I want to load my image in file.js but it throws error
<Image source={require('../assets/images/potrait.png')} />
Error:
error: Error: Unable to resolve module ../assets/images/potrait.png from D:\munish\Desktop\Invictus\reach-app\src\reactNativeCamera.js:
None of these files exist:
- potrait.png
- assets\images\potrait.png\index(.native|.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)
CodePudding user response:
Sadly, react disables imports outside of src. You should move them to inside the src or to the public
folder where it can be accessed through /
( not recommended because it will replicate the image, should be avoided for the best optimization ).
CodePudding user response:
Have you tried this syntax?
<Image source={{uri: localPath}}/>