3 Star 0 Fork 0

mirrors_shakacode/rescript-react-on-rails

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

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!

空文件

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_shakacode/rescript-react-on-rails.git
git@gitee.com:mirrors_shakacode/rescript-react-on-rails.git
mirrors_shakacode
rescript-react-on-rails
rescript-react-on-rails
master

搜索帮助