-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extract Module to Library #4274
Conversation
3. For iOS only, you need to install CocoaPods: `cd ios && pod install`. | ||
4. Build and run Android with `yarn android` from the `example` folder. | ||
5. Build and run iOS with `yarn ios` from the `example` folder. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to add a paragraph on the Local Module setup, but it is currently broken. Metro can't follow the symlinks that yarn generates and it can't pick up the JS files from the other folder.
Probably there is a way to make it work by tinkering with the metro.config.js
, but I don't think we should go to that level of details in these guides, so I decided to leave that setup out for simplicity. There is a way to test the library anyway.
cc. @huntie if you know how to handle this case in a simple way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have this page:
https://reactnative.dev/docs/next/legacy/native-modules-setup
Which can instead be revived and used for both arch no?
|
||
## Extract the Module into a Library | ||
|
||
The React Native community produced an amazing tool to scaffold a new library: the [`create-react-native-library`](https://callstack.github.io/react-native-builder-bob/create) tool. This tool sets up a new library with all the boilerplate code that is needed: all the configuration files and all files required by the various platforms. It also comes with a nice interactive menu to guide you through the creation of the library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The React Native community produced an amazing tool to scaffold a new library: the [`create-react-native-library`](https://callstack.github.io/react-native-builder-bob/create) tool. This tool sets up a new library with all the boilerplate code that is needed: all the configuration files and all files required by the various platforms. It also comes with a nice interactive menu to guide you through the creation of the library. | |
You can use the [`create-react-native-library`](https://callstack.github.io/react-native-builder-bob/create) tool to create a new library. This tool sets up a new library with all the boilerplate code that is needed: all the configuration files and all files required by the various platforms. It also comes with a nice interactive menu to guide you through the creation of the library. |
Yeah, that's what I did. This guide is a revamp of that one, and it is in the right spot:
The instructions works in the same way for both architectures. I can generalize it further to make it read better also for the old architecture. |
✅ Deploy Preview for react-native ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
ec6c0cd
to
0b33306
Compare
This PR shows how to extract a module in a library using
create-react-native-library