Open whalemare opened 2 years ago
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏
Not stale
in nx react native app, how can i use a library with react native code? Thanks in advance. @whalemare
This is very much required feature, especially for react-native
@whalemare thanks for filing this.
You can do it by generating a local RN library using create-react-native-library.
Afterwards you can manually link this library in your NX workspace by adjusting the workspace.json
and copying over any other config files in the library. Create a plain TS RN library using NX as example and copy over the files for linting, TS, ...
Note that in order for RN autolinking to work properly, you will need to add this local package as a dependency in each app that needs to use it. So you will have:
// In the root package.json the following is added by create-react-native-library:
"dependencies": {
"local-rn-library": "link:./modules/awesome-library"
}
// In the package.json of any apps that need the library you need to add:
"dependencies": {
"local-rn-library": "*"
}
Description
I want to generate react-native library that includes not only
js
code, but also native part with Kotlin, Swift https://nx.dev/packages/react-native/generators/libraryMotivation
Native dependencies it's important part of any react-native project. NX already supported react-native libraries with native code, but can't generate it yet
Suggested Implementation
Usage: something like that
yarn nx g @nrwl/react-native:library --withNativePart
Alternate Implementations
-