Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.39 KB

File metadata and controls

53 lines (40 loc) · 1.39 KB
title Installation
description Installation and Setup
canonical /docs/react/installation
section Overview
order 2

Installation

Requirements:

  • rescript@11.0 or later
  • react@18.0.0 or later

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

npm install @rescript/react

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

{
  "jsx": { "version": 4 },
  "bs-dependencies": ["@rescript/react"]
}

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

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

Now run npx rescript and you should see a successful build.

Exposed Modules

After a successful installation, @rescript/react will make the 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
  • RescriptReactErrorBoundary: A component which handles errors thrown in its child components gracefully