Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6215

React Native platform specific import only works with relative paths

$
0
0

I have a platform specific component split into 2 files:

src/components/Foo/Foo.android.tsxsrc/components/Foo/Foo.ios.tsx

I want to import it in a file:

src/screens/Login.tsx

using:

import Foo from "components/Foo/Foo"

Non-platform specific files can be imported that way because I have setup this custom tsconfig for my project:

"paths": {                                /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */"*": ["src/*"],"@components/*": ["src/components/*"],},

However RN bundler does not find the file. I can only import it using relative paths like this:

import Foo from "../../components/Foo/Foo"

I already tried to change my @components paths config to:

"@components/*": ["src/components/*", "src/components/*.android", , "src/components/*.ios"],

without success.

Any idea why the RN bundler is not able to find the import using components import path notation?


Viewing all articles
Browse latest Browse all 6215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>