bs-react-on-rails
Version:
BuckleScript bindings to react-on-rails
50 lines (33 loc) • 1.37 kB
Markdown
BuckleScript bindings to [react-on-rails](https://github.com/shakacode/react_on_rails).
```shell
yarn add bs-react-on-rails
npm install --save bs-react-on-rails
```
```reason
type props = {. "name": string};
type context = {. "host": string};
let component = (props: props, context: context) =>
<Page name=props
ReactOnRails.register("App", component);
```
See [example Rails app](https://github.com/shakacode/reason-react-on-rails-example) and [implementation commit](https://github.com/shakacode/reason-react-on-rails-example/commit/e69bed7cb5141a87edafef1b67fca1b69a48e481).
```reason
/* ReactOnRails.register */
ReactOnRails.register("App", component);
/* ReactOnRails.registerWithOptions */
ReactOnRails.registerWithOptions("App", component, {traceTurbolinks: true});
/* ReactOnRails.registerWithOptions */
let csrfToken: option(string) = ReactOnRails.authenticityToken();
/* ReactOnRails.reactOnRailsPageLoaded */
ReactOnRails.reactOnRailsPageLoaded();
```
No `redux` related methods are exposed as there're no `redux` bindings exist and it's not idiomatic way to manage state in `ReasonReact` apps.
See [`react-on-rails` JS API](https://github.com/shakacode/react_on_rails/blob/master/docs/api/javascript-api.md) for more details.
MIT.