{"id":16899913,"url":"https://github.com/bloodyowl/rescript-react-compat","last_synced_at":"2025-04-11T13:53:38.407Z","repository":{"id":57348997,"uuid":"182046287","full_name":"bloodyowl/rescript-react-compat","owner":"bloodyowl","description":"An alternative upgrade path for ReasonReact","archived":false,"fork":false,"pushed_at":"2023-08-18T16:09:23.000Z","size":56,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-04-14T08:44:32.630Z","etag":null,"topics":["compatibility-wrapper","react","reason-react","reasonml"],"latest_commit_sha":null,"homepage":null,"language":"ReScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloodyowl.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":".github/FUNDING.yml","license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["bloodyowl"]}},"created_at":"2019-04-18T08:17:07.000Z","updated_at":"2024-06-19T22:50:04.517Z","dependencies_parsed_at":"2024-06-19T22:49:58.043Z","dependency_job_id":"fe86e0ee-5912-47a7-ad67-01a148a14538","html_url":"https://github.com/bloodyowl/rescript-react-compat","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.18918918918918914","last_synced_commit":"16944e43c9ade822cef2eb19319ad349cbf8ed21"},"previous_names":["bloodyowl/reason-react-compat"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-react-compat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-react-compat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-react-compat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloodyowl%2Frescript-react-compat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloodyowl","download_url":"https://codeload.github.com/bloodyowl/rescript-react-compat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248412080,"owners_count":21099045,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compatibility-wrapper","react","reason-react","reasonml"],"created_at":"2024-10-13T17:50:54.110Z","updated_at":"2025-04-11T13:53:38.368Z","avatar_url":"https://github.com/bloodyowl.png","language":"ReScript","funding_links":["https://github.com/sponsors/bloodyowl"],"categories":[],"sub_categories":[],"readme":"# rescript-react-compat\n\n\u003e An alternative upgrade path for ReasonReact\n\n## Installation\n\n```console\n$ yarn add rescript-react-compat\n```\n\nor\n\n```console\n$ npm install --save rescript-react-compat\n```\n\nThen add `rescript-react-compat` to your `bsconfig.json` `bs-dependencies` field.\n\n## ReactCompat.useRecordApi\n\nEnables you to wrap your existing `ReasonReact.statelessComponent` and `ReasonReact.reducerComponent` through a React hook.\n\n```reason\n[@react.component]\nlet make = () =\u003e {\n  ReactCompat.useRecordApi({\n    ...ReactCompat.component,\n    render: _ =\u003e\n      \u003cdiv\u003e \"Helloworld!\"-\u003eReasonReact.string \u003c/div\u003e\n  })\n}\n```\n\n### Upgrade path\n\n#### Stateless components\n\nFor implementation files (`.re`)\n\n```diff\n-let component = ReasonReact.statelessComponent(\"MyComponent\");\n\n+[@react.component]\n- let make = _ =\u003e {\n+ let make = () =\u003e {\n+  ReactCompat.useRecordApi(\n     {\n-      ...component,\n+      ...ReactCompat.component,\n       render: _ =\u003e\n         \u003cdiv\u003e \"Helloworld!\"-\u003eReasonReact.string \u003c/div\u003e\n     }\n+  )\n }\n```\n\nFor interface files (`.rei`)\n\n```diff\n\n+[@react.component]\n- let make = 'a =\u003e\n+ let make = unit =\u003e\n-  ReasonReact.component(\n-    ReasonReact.stateless,\n-    ReasonReact.noRetainedProps,\n-    ReasonReact.actionless\n-  );\n+  React.element;\n```\n\n#### Reducer components\n\nFor implementation files (`.re`)\n\n```diff\n type action = | Tick;\n\n type state = {count: int};\n\n-let component = ReasonReact.reducerComponent(\"MyComponent\");\n\n+[@react.component]\n- let make = _ =\u003e {\n+ let make = () =\u003e {\n+  ReactCompat.useRecordApi(\n     {\n-      ...component,\n+      ...ReactCompat.component,\n       /* some lifecycle */\n       render: _ =\u003e\n         \u003cdiv\u003e \"Helloworld!\"-\u003eReasonReact.string \u003c/div\u003e\n     }\n+  )\n }\n```\n\nYou'll also need to rename:\n\n- `ReasonReact.Update` -\u003e `Update`\n- `ReasonReact.UpdateWithSideEffects` -\u003e `UpdateWithSideEffects`\n- `ReasonReact.SideEffects` -\u003e `SideEffects`\n- `ReasonReact.NoUpdate` -\u003e `NoUpdate`\n\nFor interface files (`.rei`)\n\n```diff\n-type state;\n\n-type action;\n\n+[@react.component]\n- let make = 'a =\u003e\n+ let make = unit =\u003e\n-  ReasonReact.component(\n-    state,\n-    ReasonReact.noRetainedProps,\n-    action\n-  );\n+  React.element;\n```\n\n## Acknowledgments\n\nThnks @rickyvetter for the original idea and help through the process\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloodyowl%2Frescript-react-compat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloodyowl%2Frescript-react-compat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloodyowl%2Frescript-react-compat/lists"}