• Stars
    star
    1,021
  • Rank 45,070 (Top 0.9 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A CLI tool that bridges React Native modules & UI components with ease ๐ŸŽ‰

react-native-create-bridge

Bridging native modules & UI components made easy! If you're a JavaScript developer writing your first lines of native code or a more experienced developer looking to eliminate boilerplate from your React Native workflow, this tool is for you.

CONTRIBUTORS WANTED

Getting Started

  1. npm install --save react-native-create-bridge or yarn add react-native-create-bridge
  2. From the root of your React Native project, run react-native new-module
  3. The prompts will ask you for:
  • Your bridge module name
  • Whether you want to create a native module or UI component (or both!)
  • The platforms and languages you would like to support. Currently, we default to iOS/Obj-C and Android/Java, but you can also choose iOS/Swift or Android/Kotlin if you prefer.
  • The directory where you would like your JS files. If it doesn't exist, we'll create it for you.
  1. That's it! ๐Ÿ“ฆ Sit back and we'll deliver your native module for you lightning fast! โšก๏ธ

Next Steps

Depending on your environment, there may be a couple more steps that you have to take. In future versions of react-native-create-bridge, we want to eliminate these steps.

Android/Java

  • To complete the bridging process, look for MainApplication.java in android/app/src/main/java/com/yourapp
  • Add your package to the getPackages function like this:
@Override
  protected List<ReactPackage> getPackages() {
    return Arrays.<ReactPackage>asList(
        new MainReactPackage(),
        new YourModulePackage()
    );
  }
  • Import your package at the top: import com.yourapp.yourmodule.YourModulePackage;

Android/Kotlin

Adding Kotlin support to your project:
  • You will need to install the Android Studio 3 preview
  • In android/build.gradle, add ext.kotlin_version = '1.1.2-4' to the buildscript and classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" to your dependencies
  • In android/app/build.gradle, add apply plugin: 'kotlin-android' to the top of the file. At the bottom, add compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" to your dependencies
  • Now, you can convert any Java file to a Kotlin file by navigating to Code > Convert Java file to Kotlin file in the top menu
Completing the bridging process:
  • If you already followed all the steps above, you can complete the bridging process by looking for MainApplication.kt in android/app/src/main/java/com/yourapp
  • Add your package to the getPackages function like this:
override fun getPackages(): List<ReactPackage> {
  return Arrays.asList(
      MainReactPackage(),
      YourModulePackage(),
  )
}
  • Import your package at the top: import com.yourapp.yourmodule.YourModulePackage

iOS/Obj-C

  • Currently, you will need to add the files manually to your project in Xcode. Right click on the folder with your app name and select Add Files To YourApp. Select the files associated with your module and click Add

iOS/Swift

  • If this is your first Swift module in your project, you will need to make sure you have a Obj-C bridging header to expose any Obj-C code to Swift. Read Importing Obj-C into Swift to learn more.

Goals

  • Delivers bridge module in Obj-C, Swift, Kotlin, & Java
  • Compatible with all versions of React Native, including v0.40+
  • Split out native UI components & modules into their own templates
  • Config to remove comments for more experienced users
  • Modifies existing project files (AppDelegate.h, MainApplication.java) to complete the bridging process
  • Your feature request could be here! Open up an issue and give us feedback ๐Ÿ˜Š

Setting Up Dev Environment

  1. Fork this repo & clone it
  2. cd to where you cloned it
  3. npm install or yarn
  4. After you make changes, link your local package by running npm run package:dev
  5. You can now run react-native new-module locally in a React Native project to test your changes
  6. npm run test will run the Jest test suite

Contributing

react-native-create-bridge is a new project and we would love feedback from the community on how it should evolve. Please report any ๐Ÿžs and let us know how you're using react-native-create-bridge!

If you would like to contribute, please read the contributor guidelines first.

This project adheres to the Contributor Covenant code of conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

Contributors

A big thank you goes out to these awesome people for their contributions (emoji key):


Kurtis Kemple

๐Ÿ’ป

Duy Bao Nguyen

๐Ÿ’ป

Mike Grabowski

๐Ÿ’ฌ

Peggy Rayzis

๐Ÿ’ป ๐Ÿ“– ๐Ÿ‘€

Mihovil

๐Ÿ“

Andrรฉ Neves

๐Ÿ‘€

Jarret Moses

๐Ÿ’ป ๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

More Repositories

1

redux-to-graphql

The Redux advanced tutorial app built with GraphQL and Apollo ๐Ÿš€
TypeScript
90
star
2

reactnext-universal-components

React Next 2017: Write Once, Render Anywhere (v2)
JavaScript
77
star
3

guide-to-graphql

A Frontend Developer's Guide to GraphQL (Fluent Conf 2018)
JavaScript
58
star
4

reactfest-apollo

๐Ÿš€ Give Your Data a Boost - ReactFest 2018
JavaScript
46
star
5

react-europe-apollo

A Journey through React Apollo - React Europe 2018
JavaScript
32
star
6

future-of-gql-servers

The future of GraphQL servers (GraphQL Europe 2018)
JavaScript
27
star
7

chain-react-bridging

Chain React 2017: Breaking Down React Native Bridging
JavaScript
14
star
8

react-conf-data-viz

React Conf 2017: Cross-Platform Data Visualization in React & React Native
JavaScript
13
star
9

agentconf-apollo

AgentConf 2018: Write Queries, Not Code
JavaScript
9
star
10

the-graphql-dx

The GraphQL developer experience (React Amsterdam 2019)
JavaScript
7
star
11

apollo-webdirections

Building better, faster, stronger teams with GraphQL - WebDirections 2018
JavaScript
6
star
12

classpass-bridging-workshop

Slides & sample app for bridging native modules & UI components workshop at Classpass ๐Ÿ’ช
JavaScript
5
star
13

whats-next-apollo-client

What's Next in Apollo Client by @peggyrayzis - GraphQL Summit 2018
JavaScript
4
star
14

asburyagile-universal-components

Asbury Agile 2017: Write Once, Render Anywhere
JavaScript
3
star
15

apollo-day-nyc

Apollo Day NYC - Ask the Experts demo & Q&A
JavaScript
3
star
16

myo-dj

Controlling Traktor DJ software with Myo gesture control armband.
JavaScript
2
star
17

twitter-js

HTML
1
star