All Projects → bloodyowl → rescript-react-compat

bloodyowl / rescript-react-compat

Licence: MIT License
An alternative upgrade path for ReasonReact

Programming Languages

ReScript
86 projects

Projects that are alternatives of or similar to rescript-react-compat

reason-react-lazy-loading
Example project to show how to use components lazy loading in ReasonReact
Stars: ✭ 41 (+141.18%)
Mutual labels:  reasonml, reason-react
reason-catstagram
🐈 Catstagram made with ReasonReact!
Stars: ✭ 31 (+82.35%)
Mutual labels:  reasonml, reason-react
LifeTime
LifeTime app
Stars: ✭ 35 (+105.88%)
Mutual labels:  reasonml, reason-react
re-typescript
An opinionated attempt at finally solving typescript interop for ReasonML / OCaml.
Stars: ✭ 68 (+300%)
Mutual labels:  reasonml, reason-react
onetricks.net
(WIP) kayn-powered (typescript node.js) ReasonReact app presenting you a dashboard of high ELO one trick ponies in League of Legends
Stars: ✭ 13 (-23.53%)
Mutual labels:  reasonml, reason-react
reason-hooks-testing-library
ReasonML bindings for react-hooks-testing-library
Stars: ✭ 24 (+41.18%)
Mutual labels:  reasonml, reason-react
react-multiversal
React components that works everywhere (iOS, Android, Web, Node)
Stars: ✭ 43 (+152.94%)
Mutual labels:  reasonml, reason-react
Reason Graphql Fullstack
Fullstack Reason + GraphQL Todo List App
Stars: ✭ 246 (+1347.06%)
Mutual labels:  reasonml, reason-react
timerlab
⏰ A simple and customizable timer
Stars: ✭ 94 (+452.94%)
Mutual labels:  reasonml, reason-react
dokusho
Simple Japanese reading stats tracker
Stars: ✭ 12 (-29.41%)
Mutual labels:  reasonml, reason-react
re-use
⚛️ 🎣 A collection of hooks for ReasonReact
Stars: ✭ 27 (+58.82%)
Mutual labels:  reasonml, reason-react
credt
CRDT-like data structures for building distributed, offline-first applications
Stars: ✭ 32 (+88.24%)
Mutual labels:  reasonml, reason-react
bs-rsuite-ui-react
Reason bindings for React Suite UI library
Stars: ✭ 26 (+52.94%)
Mutual labels:  reasonml, reason-react
re-cite
Manage citations from your colleagues , friends, movies, your cat or even yourself.
Stars: ✭ 20 (+17.65%)
Mutual labels:  reasonml, reason-react
app-template-rescript-react
Adding ReScript with rescript-react on top of @snowpack/app-template-react
Stars: ✭ 44 (+158.82%)
Mutual labels:  reasonml, reason-react
Reason-react-hooks
🧶 Some hooks in ReasonML for reason-react that can be useful
Stars: ✭ 14 (-17.65%)
Mutual labels:  reasonml, reason-react
Bs Material Ui
ReScript bindings for material-ui
Stars: ✭ 185 (+988.24%)
Mutual labels:  reasonml, reason-react
Rescript Relay
Use Relay with ReasonML.
Stars: ✭ 214 (+1158.82%)
Mutual labels:  reasonml, reason-react
qnd
Quick and Dirty development builds
Stars: ✭ 19 (+11.76%)
Mutual labels:  reasonml, reason-react
reason-rt-binding-generator
Reason binding generator for react-toolbox
Stars: ✭ 18 (+5.88%)
Mutual labels:  reasonml, reason-react

rescript-react-compat

An alternative upgrade path for ReasonReact

Installation

$ yarn add rescript-react-compat

or

$ npm install --save rescript-react-compat

Then add rescript-react-compat to your bsconfig.json bs-dependencies field.

ReactCompat.useRecordApi

Enables you to wrap your existing ReasonReact.statelessComponent and ReasonReact.reducerComponent through a React hook.

[@react.component]
let make = () => {
  ReactCompat.useRecordApi({
    ...ReactCompat.component,
    render: _ =>
      <div> "Helloworld!"->ReasonReact.string </div>
  })
}

Upgrade path

Stateless components

For implementation files (.re)

-let component = ReasonReact.statelessComponent("MyComponent");

+[@react.component]
- let make = _ => {
+ let make = () => {
+  ReactCompat.useRecordApi(
     {
-      ...component,
+      ...ReactCompat.component,
       render: _ =>
         <div> "Helloworld!"->ReasonReact.string </div>
     }
+  )
 }

For interface files (.rei)

+[@react.component]
- let make = 'a =>
+ let make = unit =>
-  ReasonReact.component(
-    ReasonReact.stateless,
-    ReasonReact.noRetainedProps,
-    ReasonReact.actionless
-  );
+  React.element;

Reducer components

For implementation files (.re)

 type action = | Tick;

 type state = {count: int};

-let component = ReasonReact.reducerComponent("MyComponent");

+[@react.component]
- let make = _ => {
+ let make = () => {
+  ReactCompat.useRecordApi(
     {
-      ...component,
+      ...ReactCompat.component,
       /* some lifecycle */
       render: _ =>
         <div> "Helloworld!"->ReasonReact.string </div>
     }
+  )
 }

You'll also need to rename:

  • ReasonReact.Update -> Update
  • ReasonReact.UpdateWithSideEffects -> UpdateWithSideEffects
  • ReasonReact.SideEffects -> SideEffects
  • ReasonReact.NoUpdate -> NoUpdate

For interface files (.rei)

-type state;

-type action;

+[@react.component]
- let make = 'a =>
+ let make = unit =>
-  ReasonReact.component(
-    state,
-    ReasonReact.noRetainedProps,
-    action
-  );
+  React.element;

Acknowledgments

Thnks @rickyvetter for the original idea and help through the process

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].