Thank you for your support to this library. This documentation will help you how to contribute to this library. There are some requirements and conventions that we and i must fill and follow.
- Knowledges
- Environments
- Clone
- Setup
- Run the Example App
- Conventions
- About the Example App and the Library in Monorepo Setup
To contribute to this project, we assummed that you know about app development with React Native including:
- JavaScript or TypeScript language as the bridge for library users to consume native modules of platform and for the build user interface with React.js in the React Native app
- Java or Kotlin for Android library development
- Objective-C for iOS and macOS library development. Optionally, you can use Swift language. The library currently does not contain any Swift code due to the Swift bridging header performance, but it's not prohibited to use
- Turbo Native Modules for React Native module development with new architecture. You can also refer to the reactwg documentation for additional information about React Native New Architecture
- Legacy Native Modules for React Native module development with old/legacy architecture
- A bit of react-native-builder-bob knowledges as the builder for React Native libraries for various targets
You don't have to know it all at advanced level. Feel free to learn and embrace it. Do the actual fix and any improvements. I encourage you.
Before you clone this repository, you need to add these in your machine
- Node.js >=22
- PNPM >= 10
- Visual Studio Code (Optional)
- Android Studio with Meerkat version or latest version for Android development
- Xcode latest version for iOS and macOS development
- Ruby >= 3.3.6 for iOS and macOS development. You can use ruby-install to install other Ruby versions with chruby to easily switch Ruby version
Clone this repository in your machine
git clone https://github.com/RakaDoank/ping-react-native.git
Make your environment is ready and the repository has been cloned. After that, do these next steps
Go to the repository's directory in your terminal or cmd and do the installation with your pnpm
pnpm install
This installation will install all the npm dependencies including the react-native example app.
In this project, the example app at the ping-react-native/examples/{expo,macos} directory is the app we will use as the library playground to use for the library development. The app was bootstrapped with @react-native-community/cli with some modificiations.
To setup the React Native app and link the library (ping-react-native) itself are similar like the usual React Native CLI installation with autolinking of React Native libraries
- Open the
ping-react-native/examples/expo/androiddirectory with Android Studio - Sync project with gradle files
- You should see
ping-react-nativein the sidebar explorer of Android Studio withAndroidmode directory. This is where the library code lives you can actually do any fixes
Beforehand, make sure you are with Ruby >= 3.3.6 version
- Open your terminal
- Go to
ping-react-native/examples/expo/iosdirectory for iOS, or go toping-react-native/examples/macosdirectory for macOS - Install the pods by run this command
bundle install && bundle exec pod install
- Open Xcode app, and open the
ping-react-native/examples/expo/{ios,macos}/{projectName}.xcworkspace - You should see
RNPingfolder in thePods > Development Toolsfrom the sidebar navigator. This is where the library code lives you can actually do any fixes - (
⚠️ For macOS only) you need to patch some files to make the app run properly because react-native scripts are pointing to the wrongnode_modulespath. See this README.md
For Android, you need to run with physical Android devices. See Emulator Networking. Connect your Android with USB or you can connect it over Wi-Fi. Run adb devices in your terminal or cmd, and make sure your devices are listed.
After that, you can run the app. Go to examples/expo directory, run npm run android. Alternatively, you can run the metro first by execute npm run start, and then run npm run android later.
For iOS, you need run your iPhone/iPad Simulator first.
After it's completely booted up, you can run the app. Go the examples/expo directory, run npm run ios. Alternatively, you can run the metro first by execute npm run start, and then run npm run ios later.
For macOS, go to examples/macos. In the directory, run the metro first by execute npm run start, and then run npm run macos.
All the JavaScript/TypeScript has been lint-checked with ESLint, and type-checked with TypeScript. Please follow the rule that has been made e.g indentation with Tab. Do not modify the rule or add // eslint-disable mark to your code with no reasons.
While development, ensure that your ESLint Extension of your Visual Studio Code is running if you are using that IDE. Alternatively, you can run npm run code-check in the root of repository.
You can check the lint rules at ping-react-native/eslint.config.mjs and the compilerOptions of TypeScript at ping-react-native/tsconfig.base.json and other tsconfig.json files in the examples/* and package directory.
The convention for the project for Java/Kotlin code is only indentatation with Tab
Please, follow the Google Objective-C Style Guide.
.github: You don't have to worry about this directoryexamples: This is the actual of React Native app as the playground of the library development. For Android & iOS, it lives inexamples/expodirectory, and macOS inexamples/macospackage: This is the actualping-react-nativelibrary source code lives. This directory will be used as the actualping-react-nativelibrary in the npm registrypackage-builder: This directory is for the builder of the actual library with hard-coded path configuration to thepackagedirectory. You can read this documentation
The app was actually bootstrapped with npx create-expo-app@latest, but since this project is a monorepo setup with PNPM to scaffold both app and actual library deployment. There are modifications that have been done in the example app to split between the app, the actual material-color-react-native library, and other development tools or the devDependencies
ping-react-native/examples/{expo,macos}/metro.config.js: The example app has to know where thenode_modulesand the actualping-react-nativedirectory lives without including theping-react-nativein thedependenciesof thepackage.jsonexample appping-react-native/examples/{expo,macos}/react-native.config.js: Since the actualping-react-nativelibrary is not included asdependenciesin thepackage.jsonfile of example app, we have to tell React Native CLI where theping-react-nativedirectory lives to auto-linked the example app withping-react-nativelibrary in development@react-native/eslint-configdevelopment dependency (devDependencies) was moved out to the root ofpackage.json(repository) from theexampleapp