Git Product home page Git Product logo

react-native-codegen's Introduction

React Native Code Generation

The purpose of this project is to ease the integration of React Native into large production apps, so React Native adoption can happen incrementally, with minimal friction.

ReactNativeCodeGen takes a flowtype type definition of the props a React Native component expects and generates java and swift code to marshall the data, including functions and structs. The resulting class is then usable within the context of a typical iOS or Android app.

Status

Swift support is complete enough to be going on with, although some types are not yet supported.

Java support has not yet begun.

Requirements

  • nodejs (5 is probably safest, but probably others work too)
  • flow (brew install flow)

Installation

(probably, not solidified) Once you've installed react-native via npm, just also install react-native-codegen. Then to run the codegen, you can add a scripts entry to your package.json:

"scripts": {
  "codegen": "react-native-codegen ./codegen.yaml"
}

or something like that. Then if you run npm run codegen your files will be generated for you.

Usage

ReactNativeCodeGen uses a configuration file, typically called codegen.yaml. See the codegen.yaml in this directory for an example. It defines both the Root components that are to be processed as well as a mapping from flowtype struct definitions to the swift/java equivalent.

babel-node run.js my-config.yaml will generate the files necessary to bind.

Config file format

entries:
  MyGreatRNView:
    source: "./path/to/main/file.js"
    dest: "./place/to/put/generated/files/"
  OtherRNView:
    ...

types:
  "./path/to/a/file/with/a/type/in/it.js":
    NameOfFlowType:
      swift: CorrespondingSwiftType
      java: com.example.CorrespondingJavaType
    ...
  ...

Developing

Run npm install and then npm run example to generate the example bridge files, defined in ./example/codegen.yaml.

TODO

Swift

  • Array<> types
  • sum types

Java

  • Array<> types
  • enum types

react-native-codegen's People

Contributors

jaredly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

infie prituladima

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.