Socket
Book a DemoInstallSign in
Socket

bs-react

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bs-react

Minimal React bindings for Reason

Source
npmnpm
Version
0.0.2
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

BsReact

npm install --save bs-react

BsReact is a fork of ReasonReact adapted to work with Hooks, with Hooks types from Jared Forsyth.

Reason React uses the good old createClass under the hood. BsReact has a simplified api that converts components defined in Reason to plain function components, allowing hooks to be used.

API

The api is similar to ReasonReact, but there's only one type of component, and you can only define a render function.

Example:

module Counter = {
  let component = ReasonReact.component("Counter");

  let make = (~initial=0, _children) => {
    ...component,
    render: _self => {
      let (count, setCount) = Hooks.useState(initial);
      <div>
        {ReasonReact.string(string_of_int(count))}
        <button onClick={_ => setCount(. count + 1)}>
          {ReasonReact.string("Click me")}
        </button>
      </div>;
    },
  };
};

Status

Very early experimentation. Only for the brave, not for production. Some things are broken.

Let's chat on Discord!

Keywords

reasonml

FAQs

Package last updated on 16 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts