5
27%
MIT
BuckleScript bindings to react-on-rails

bs-react-on-rails

BuckleScript bindings to react-on-rails.

Installation

# yarn
yarn add bs-react-on-rails

# or npm
npm install --save bs-react-on-rails

Usage

  • RE
  • ML
type props = {. "name": string};

type context = {. "host": string};

let component = (props: props, context: context) =>
  <Page name=props##name host=context##host />;

ReactOnRails.register("App", component);
type props = < name :string  > Js.t
type context = < host :string  > Js.t
let component (props : props) (context : context) =
  ((Page.createElement ~name:(## props name) ~host:(## context host)
      ~children:[] ())[@JSX ])
let _ = ReactOnRails.register "App" component

See example Rails app and implementation commit.

API

  • RE
  • ML
/* 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();
let _ = ReactOnRails.register "App" component
let _ =
  ReactOnRails.registerWithOptions "App" component { traceTurbolinks = true }
let csrfToken: string option = ReactOnRails.authenticityToken ()
let _ = 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 for more details.

License

MIT.