Coder Social home page Coder Social logo

vitalybe / reactnativeuniversal Goto Github PK

View Code? Open in Web Editor NEW
177.0 9.0 14.0 2.13 MB

A demonstration of sharing javascript react-native code between mobile, desktop and web environments

License: MIT License

JavaScript 87.49% Python 2.81% Java 2.18% HTML 0.36% Objective-C 7.17%
react-native boilerplate electron react-native-web sample

reactnativeuniversal's Introduction

Universal React - Android, Electron (Desktop) and Web

Electron Web
Android iOS

About

This sample demonstrates the usage of React Native in in the desktop, web and mobile environment using the same code.

Components or services that should differ between the platforms are easy to to include using a predefined suffix.

What's included

The following features are included and demonstrated:

  • Using shared components (e.g using Ball.js in BallsList.js)
  • Using platform specific components (e.g using PlatformSpecificBall.js in BallsList.js)
  • Packaging production build for Web and Electron (for Android follow the official guide)
  • React Native's ListView
  • React Native's Animations

Running

The following commands are available:

  • yarn run web - Web development
  • yarn run web-build - Web production package
  • yarn run desktop - Electron development
  • yarn run desktop-build - Electron production package
  • yarn run android - Android development

Structure

Platform specific components

By default all the javascript files are shared by all the platforms. To create a platform specific file, suffix it accordingly.

For example if you have a generic Ball.js file and would like Electron to have its own platform specific version, we'd create a new file Ball.electron.js.

The file will be imported everywhere without extension: import Ball from './Ball. All the platforms will import the generic file and only Electron will import its own platform file.

This mechanism is achieved by Webpack's extension resolution.

Web and Electron

Powered by the react-native-web project.

Webpack configuration (in webpack/config) are based on the scripts of create-react-app with only minor changes that allows it to be updated by future changes.

What's missing

Missing features:

  • Test

License

This project is MIT licensed.

reactnativeuniversal's People

Contributors

ckalpit avatar vitalybe avatar

Stargazers

 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  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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reactnativeuniversal's Issues

Packaging for production ignores node-modules

Node modules don't seem to get packaged when running desktop-build. As a very simply example, if we install lodash and simply require it in index.web.js, creating a production build, though successful, resulting in an error when the executable is run (module lodash not found).

Not very familiar with webpack so simply reporting the issue for now -- if I do manage to fix the problem I'll do a pull request.

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.