|
| 1 | +# HelloWorld |
| 2 | + |
| 3 | +> This is a React Native application developed in Reason. |
| 4 | +
|
| 5 | +## Installation |
| 6 | + |
| 7 | +To get started, add the following scripts to your `package.json`: |
| 8 | + |
| 9 | +```json |
| 10 | +"scripts": { |
| 11 | + "start": "node node_modules/react-native/local-cli/cli.js start", |
| 12 | + "build": "bsb -make-world -clean-world", |
| 13 | + "watch": "bsb -make-world -clean-world -w" |
| 14 | +} |
| 15 | +``` |
| 16 | + |
| 17 | +Next, run `watch` and `start` scripts from the command line so that both processes are running at the same time. This can be done with `yarn` (e.g. `yarn watch`) or `npm` (e.g. `npm run watch`). |
| 18 | + |
| 19 | +The first script compiles you Reason code in a watch mode, meaning that every change is instantly recompiled. |
| 20 | + |
| 21 | +Second one is a React Native packager that serves the compiled Reason code to the React Native client. |
| 22 | + |
| 23 | +## Hiding `.bs.js` files |
| 24 | + |
| 25 | +Bucklescript compiles your Reason files to Javascript `in source`, meaning that `App.re` will result in `App.bs.js` file generated next to it. |
| 26 | + |
| 27 | +These are build files and are by default ignored from the git repository. |
| 28 | + |
| 29 | +If you are using VSCode, you can add the following to your workspace settings to hide them automatically: |
| 30 | + |
| 31 | +```json |
| 32 | +{ |
| 33 | + "files.exclude": { |
| 34 | + "**/*.bs.js": true |
| 35 | + } |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +## Breakdown of existing files |
| 40 | + |
| 41 | +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: |
| 42 | + |
| 43 | +- `.babelrc` - required, for transpiling Javascript files to supported by the mobile engine Javascript version |
| 44 | +- `.buckconfig` - optional, configuration files for `Buck`. Can be safely removed in most cases unless you are planning on using it |
| 45 | +- `.flowconfig` - optional, used to configure `Flow`, which is a type checker for Javascript. Can be removed as we are writing our code in Reason now |
| 46 | +- `.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 right now |
| 47 | +- `app.json` - optional, usually generated when you `eject` from an `Expo` or `create-react-native-app` project. Can be removed without any issues |
0 commit comments