Replies: 4 comments 10 replies
-
It's mentioned under "Aliasing the JavaScript Code" https://github.com/callstack/react-native-builder-bob#how-does-the-library-get-linked-to-the-example-app-in-the-generated-project. Is there anything unclear there? You can generate a project with |
Beta Was this translation helpful? Give feedback.
-
I read "Aliasing the JavaScript Code" carefully, and followed it to update metro.config.js and babel.config.js for my project. Like I said, it builds and runs fine. The only issue is that in Visual Studio Code, the red wiggly underline is shown under the library name, saying it cannot find the library. My question is how to avoid this issue. |
Beta Was this translation helpful? Give feedback.
-
All I can think of to change in tsconfig.json is this in the library:
I think the above configuration is correct. It points to the correct location. Do you think if I change something in here, like the baseUrl, then I don't need to have a path when importing it into a react native app outside of this library? Probably not. All I want to know is if I import the library into a react-native app outside of this library, how can I avoid using path, like: |
Beta Was this translation helpful? Give feedback.
-
All I can think of is to update tsconfig.json in the react native app project, not the library. So I added baseUrl and paths like this:
But I don't see the red wiggly line gone. I still need to use the path. |
Beta Was this translation helpful? Give feedback.
-
I created a library using create-react-native-library. When I was working on the example react native inside the library, I can import without including the path, i.e., I don't need "../my-library". I wonder is there some setup to do to avoid the path?
I created an independent react native app, and I put it next to the library. I followed "How does the library get linked to the example app in the generated project?" in FAQ to include the library in the react native app. This is because my library has a lot of native code. The problem I have is that if I don't use a path, for example:
import { someFunction} from 'my-library'
, it will complain that it cannot find the module, although the app still runs fine. I found that if I import like this:import { someFunction} from '../..my-library'
, then error is gone, and the app still runs fine.My question is how can I avoid the path, just like how this is achieved in the example app?
Beta Was this translation helpful? Give feedback.
All reactions