# react-native-nw-react-calculator **Repository Path**: mirrors_sudoconf/react-native-nw-react-calculator ## Basic Information - **Project Name**: react-native-nw-react-calculator - **Description**: Mobile, desktop and website Apps with the same code - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-26 - **Last Updated**: 2026-03-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Mobile, desktop and website Apps with the same code [![Build Status](https://travis-ci.org/benoitvallon/react-native-nw-react-calculator.svg?branch=master)](https://travis-ci.org/benoitvallon/react-native-nw-react-calculator) [![Dependency Status](https://david-dm.org/benoitvallon/react-native-nw-react-calculator.svg)](https://david-dm.org/benoitvallon/react-native-nw-react-calculator) [![devDependency Status](https://david-dm.org/benoitvallon/react-native-nw-react-calculator/dev-status.svg)](https://david-dm.org/benoitvallon/react-native-nw-react-calculator#info=devDependencies) This project shows how the source code can be architectured to run on multiple devices. As of now, it is able to run as: - iOS & Android Apps (based on [react-native](https://facebook.github.io/react-native)) - a Desktop App (based on [NW](http://nwjs.io)) - a Website App in any browser (based on [react](https://facebook.github.io/react)) A demo for the Website App is available [here](http://benoitvallon.github.io/react-native-nw-react-calculator). ## Screenshots ### Mobile Apps (iOS & Android) ![Mobile Apps](images/mobile-apps.png "Mobile Apps") ### Desktop App ![Desktop App](images/desktop-app.png "Desktop App") ### Website App ![Website App](images/website-app.png "Website App") ## Libraries/tools This project uses libraries and tools like: - es6 syntax and [babel](https://babeljs.io) - [react](https://facebook.github.io/react) for the Website App and Desktop App, - [react-native](https://facebook.github.io/react-native) for the iOS & Android Apps - [NW](http://nwjs.io) to package the Desktop App - [flux](https://facebook.github.io/flux) to organize the data flow management - [css-loader](https://github.com/webpack/css-loader) to integrate the styles in the builds - [grunt](http://gruntjs.com) to create the builds - [webpack](https://webpack.github.io) to help during the development phase with hot reloading ## Basic philosophy All the code is contained in the `src` directory, especially the 3 main entry files that are used for the builds: - `index.ios.js` & `index.android.js` are the ones used to build the iOS & Android Apps - `index.js` is the one used to build the Website App and Desktop App as the code is strictly the same. ### Flux architecture actions/stores All the [flux](https://facebook.github.io/flux) architecture is share to 100% to all the different builds. This means that all the logic and data management code is done only once and reuse everywhere. This allows us to have an easy tests suite as well and to ensure that our code is working properly on all the devices. ### Components The real interest of the project is in how the components have been structured to shared most of their logic and only redefined what is specific to every device. Basically, every component has a main `Class` which inherits a base `Class` containing all the logic. Then, the main component import a different Render function which has been selected during the build. The file extension `.ios.js`, `.android.js` or `.js` is used by the build tool to import only the right file. The `.native.js` files contain code that is shared between both mobile platforms (iOS & Android). Currently, the `.ios.js` and `.android.js` files compose this `.native.js` file since all code is shared right now. However, if a component needed to be different for platform specific reasons, that code would be included in the corresponding platform specific files. At the end, every component is defined by 6 files. If we look at the screen component, here is its structure. ``` Screen.js |-> ScreenBase.js |-> ScreenRender.ios.js (specific to iOS build) |-> ScreenRender.android.js (specific to Android build) |-> ScreenRender.native.js (shared mobile app code - iOS & Android) |-> ScreenRender.js (used during Website and Desktop build) ``` And here is the main `Class` file which composes the files. ```js 'use strict'; import Base from './ScreenBase'; import Render from './ScreenRender'; export default class Screen extends Base { constructor (props) { super(props); } render () { return Render.call(this, this.props, this.state); } } ``` ## What's next Here are some thoughts about what can come next: - Make the Website App Isomorphic/Universal ## Thank you Robert for your awesome design I want to thank Robert O'Dowd who kindly authorized me the reuse his very beautiful design. The original design made by Robert was part of his project called "Simplifycation" visible [here](https://dribbble.com/shots/1973851-Simplifycation). # How to build/run the projects ## General requirements before running any specific project - `npm install` to install all the dependencies, React and React Native among others. ### With some versions of npm (