|
| 1 | +# React Native HelloWorld |
| 2 | + |
| 3 | +> This is a React Native application developed in Reason. |
| 4 | +
|
| 5 | +Please carefully read instructions below in order to enjoy |
| 6 | +ReasonML development experience. |
| 7 | + |
| 8 | +## Setup |
| 9 | + |
| 10 | +### IDE |
| 11 | + |
| 12 | +To get the best development experience possible, we recommend you to use [VSCode](https://code.visualstudio.com) with [Reason Language Server](https://marketplace.visualstudio.com/items?itemName=jaredly.reason-vscode) extension & optionally [Flow Language Server](https://marketplace.visualstudio.com/items?itemName=flowtype.flow-for-vscode) extension if you have JavaScript covered by Flow. |
| 13 | + |
| 14 | +If you won't want to use VSCode, at least [get a ReasonML editor plugin](https://reasonml.github.io/docs/en/editor-plugins/). |
| 15 | + |
| 16 | +### `package.json` |
| 17 | + |
| 18 | +To get started, add the following scripts to your `package.json`: |
| 19 | + |
| 20 | +```json |
| 21 | +"scripts": { |
| 22 | + "re:watch": "bsb -clean-world -make-world -w", |
| 23 | + "re:build": "bsb -clean-world -make-world", |
| 24 | + "start": "node node_modules/react-native/local-cli/cli.js start", |
| 25 | + "start:ios": "react-native run-ios", |
| 26 | + "start:android": "react-native run-android", |
| 27 | +} |
| 28 | +``` |
| 29 | + |
| 30 | +Note: you probably have `start` already. |
| 31 | + |
| 32 | +### Development workflow |
| 33 | + |
| 34 | +_Note: `yarn` can be replaced by `npm run` in all commands below._ |
| 35 | + |
| 36 | +Depending on your editor & [its ReasonML integration](https://reasonml.github.io/docs/en/editor-plugins/) you might need to use: |
| 37 | + |
| 38 | +```console |
| 39 | +yarn re:watch |
| 40 | +``` |
| 41 | + |
| 42 | +**Reminder: this step might be unecessary if your editor can handle ReasonML compilation by its own.** |
| 43 | +[Read more](https://github.com/jaredly/reason-language-server#installation). |
| 44 | + |
| 45 | +As soon as `.re` files are being compiled to `.bs.js`, you can either start the project on _iOS Simulator_ (included in _Xcode_) or an Android Emulator (if you are unfamiliar with _Android Studio_, you might be interested by [Genymotion](https://www.genymotion.com)). |
| 46 | + |
| 47 | +```console |
| 48 | +yarn start:ios |
| 49 | +``` |
| 50 | + |
| 51 | +or |
| 52 | + |
| 53 | +```console |
| 54 | +yarn start:android |
| 55 | +``` |
| 56 | + |
| 57 | +This commands should open up a virtual device & start React Native [metro bundler](https://github.com/facebook/metro). This packager will serves the compiled Reason code to the React Native client. |
| 58 | + |
| 59 | +Now you can start coding by editing files in `src/`! |
| 60 | + |
| 61 | +[Read more about starting the project in your environment of choice](http://facebook.github.io/react-native/docs/getting-started). |
| 62 | + |
| 63 | +**Note: as soon as you have the app installed in a simulator/emulator, you could just run** |
| 64 | + |
| 65 | +```console |
| 66 | +yarn start |
| 67 | +``` |
| 68 | + |
| 69 | +This avoid rebuilding the entire native parts & will just start React Native metro bundler. |
| 70 | + |
| 71 | +## Breakdown of existing files |
| 72 | + |
| 73 | +The `react-native init` command generates a lot of boilerplate with files that might be not needed for your particular use case. Below is a breakdown of all top-level files to help you decide: |
| 74 | + |
| 75 | +- `.babelrc` - required, for transpiling Javascript files to supported by the mobile engine Javascript version |
| 76 | +- `.buckconfig` - optional, configuration files for `Buck`. Can be safely removed in most cases unless you are planning on using it |
| 77 | +- `.flowconfig` - optional, used to configure `Flow`, which is a type checker for Javascript. Can be removed as you are writing our code in Reason |
| 78 | +- `.watchmanconfig` - optional, configuration for `Watchman`, which is a Facebook tool for listening to file system changes. This file is not needed, unless you plan on extending its configuration |
0 commit comments