0.0.3 • Published 7 years ago
bs-expo v0.0.3
bs-expo
These are unoffical reasonml
bindings to the expo
JS SDK.
Getting started
See test-app for a working expo example.
Great that you want to use Reason with Expo/ReactNative! To get everything running are just a couple of steps. Let's assume that you already have a React Native project. Otherwise follow the ReactNative instructions until you have your app running.
- Install Bucklescript
(the Reason -> JS compiler),
Reason-React and
bs-react-native
:
# substitute yarn with npm if you prefer
yarn add bs-platform reason-react bs-react-native bs-expo
- Create a
re
folder (there will be your Reason code) - Create a
bsconfig.json
with the following content file in your project root
{
"name": "my-awesome-app",
"reason": {
"react-jsx": 2
},
"bsc-flags": ["-bs-super-errors"],
"bs-dependencies": ["bs-react-native", "reason-react", "bs-expo"],
"sources": [{
"dir": "re"
}],
"refmt": 3
}
- You are nearly done, the last configuration before we get to the fun stuff. In your
package.json
add to the"scripts"
section two scripts:
"scripts": {
...
"build": "bsb -make-world -clean-world",
"watch": "bsb -make-world -clean-world -w"
}
- Now you can build all your (so far nonexsisting) Reason in two modes:
yarn run build
performs a single buildyarn run watch
enters the watch mode
- Now we come to the fun stuff! Create a new file
re/app.re
and make it look like this:
open BsReactNative;
let app = () =>
<View style=Style.(style([flex(1.), justifyContent(Center), alignItems(Center)]))>
<Text value="Reason is awesome!" />
</View>;
and start the watcher with yarn run watch
if you haven't done it yet.
- We are nearly done! We now have to adapt
App.js
import { app } from "./lib/js/re/app.js";
export default app;
Helping out
Lots of easy to finish tasks, just do yarn start
and you'll see all
the compiler errors to fix.