Skip to content

shakacode/rescript-react-on-rails

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rescript-react-on-rails

ReScript bindings to react-on-rails.

Installation

# yarn
yarn add rescript-react-on-rails

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

Usage

type props = {"name": string};

type context = {"host": string};

let component = (props: props, context: context) => {
  // ReactOnRails require a component as return (not a react element)
  // That can be done by wrapping the return with a function
  (. ()) => <Page name={props["name"]} host={context["host"]} />
}

ReactOnRails.register("App", component)

See example Rails app

API

// ReactOnRails.register
ReactOnRails.register("App", component);

// ReactOnRails.registerWithOptions
ReactOnRails.registerWithOptions("App", component, {traceTurbolinks: true});

// ReactOnRails.authenticityToken
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 ReScriptReact apps.

See react-on-rails JS API for more details.

License

MIT.

Supporters

JetBrains ScoutAPM
BrowserStack Rails Autoscale Honeybadger

The following companies support our open source projects, and ShakaCode uses their products!

About

BuckleScript bindings to react-on-rails

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •