Docs / rescript-react / Installation
Edit

Installation

Important: The rescript-react npm package has not been released yet. Please stay tuned for further announcements!

Add following dependency to your ReScript project (in case you don't have any project yet, check out the installation instructions in the manual):

npm install @rescript/rescript-react --save

Then add the following setting to your existing bsconfig.json:

JSON
{ "reason": { "react-jsx": 3 }, "bs-dependencies": ["@rescript/rescript-react"] }

To test your setup, create a new .res file in your source directory and add the following code:

RES
// src/Test.res @react.component let make = () => { <div> {React.string("Hello World")} </div> }

Now rerun your build with bsb -make-world and you should see a successful build.

Exposed Modules

After a successful installation, rescript-react will make following modules available in your project's global scope:

  • React: Bindings to React

  • ReactDOM: Bindings to the ReactDOM

  • ReactDOMServer: Bindings to the ReactDOMServer

  • ReactEvent: Bindings to React's synthetic events

  • ReactDOMStyle: Bindings to the inline style API

  • RescriptReactRouter: A simple, yet fully featured router with minimal memory allocations

Deprecated Modules

rescript-react has gone a long way, so we still keep around a few modules for legacy reasons. We will deprecate them in the future in favor of...

  • ReactDOMRe -> ReactDOM

Actual usage and for each module will be discussed in the rest of this documentation.