{"id":15640568,"url":"https://github.com/jaredly/hooks-experimental","last_synced_at":"2025-04-30T08:12:27.958Z","repository":{"id":66952735,"uuid":"155221464","full_name":"jaredly/hooks-experimental","owner":"jaredly","description":"An experiment using react's new \"hooks\" with ReasonReact","archived":false,"fork":false,"pushed_at":"2018-10-30T13:21:35.000Z","size":235,"stargazers_count":75,"open_issues_count":0,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-30T08:12:19.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaredly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-10-29T14:01:25.000Z","updated_at":"2021-08-30T15:14:56.000Z","dependencies_parsed_at":"2023-05-15T18:30:54.605Z","dependency_job_id":null,"html_url":"https://github.com/jaredly/hooks-experimental","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fhooks-experimental","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fhooks-experimental/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fhooks-experimental/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaredly%2Fhooks-experimental/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaredly","download_url":"https://codeload.github.com/jaredly/hooks-experimental/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251666337,"owners_count":21624295,"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":[],"created_at":"2024-10-03T11:37:29.195Z","updated_at":"2025-04-30T08:12:27.939Z","avatar_url":"https://github.com/jaredly.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hooks-experimental\nAn experiment using react's new \"hooks\" with ReasonReact\n\nWARNING: Do not use for anything real.\n\n## How to use\n\n### 1) the package.json\n\nNOTE: You *must* use yarn, so that we can override reason-react's react dependencies with `resolutions`.\n\n```\n  \"resolutions\": {\n    \"**/react\": \"16.7.0-alpha.0\",\n    \"**/react-dom\": \"16.7.0-alpha.0\"\n  },\n  \"dependencies\": {\n    \"react\": \"16.7.0-alpha.0\",\n    \"react-dom\": \"16.7.0-alpha.0\",\n    \"reason-react\": \"^0.5.3\",\n    \"hooks-experimental\": \"github:jaredly/hooks-experimental\"\n  }\n```\n\n### 2) the bsconfig.json\n\nNothing special here, just add `\"hooks-experimental\"` to `\"bs-dependencies\"`.\n\n### 3) making a component!\n\n```re\nmodule ReasonReact = Hooks.ReasonReact;\n\nmodule FancyCounter = {\n  let component = (. props: {. \"initialValue\": int}) =\u003e {\n    let (count, setCount) = Hooks.useState(props##initialValue);\n\n    \u003cdiv\u003e\n      \u003ch1\u003e {ReasonReact.string(string_of_int(count))} \u003c/h1\u003e\n      \u003cbutton onClick={_evt =\u003e setCount(. count + 1)}\u003e\n        {ReasonReact.string(\"Count Up To The Moon\")}\n      \u003c/button\u003e\n    \u003c/div\u003e;\n  };\n  component-\u003eHooks.setName(\"Just\");\n\n  let make = (~initialValue, _children) =\u003e\n    Hooks.createElement(\n      ~component,\n      ~props={\"initialValue\": initialValue},\n    );\n};\n\nReactDOMRe.renderToElementWithId(\u003cFancyCounter initialValue=10 /\u003e, \"root\");\n```\n\n### 4) Hooks API\n\n```\n[@bs.module \"react\"] external useState: 'a =\u003e ('a, (. 'a) =\u003e unit) = \"\";\n\n[@bs.module \"react\"] external useEffect: ((unit) =\u003e (unit =\u003e unit)) =\u003e unit = \"\";\n[@bs.module \"react\"]\nexternal useMutationEffect: ((unit) =\u003e (unit =\u003e unit)) =\u003e unit = \"\";\n[@bs.module \"react\"]\nexternal useLayoutEffect: ((unit) =\u003e (unit =\u003e unit)) =\u003e unit = \"\";\n\n[@bs.module \"react\"]\nexternal useEffectWithoutCleanup: (unit =\u003e unit) =\u003e unit = \"useEffect\";\n[@bs.module \"react\"]\nexternal useMutationEffectWithoutCleanup: (unit =\u003e unit) =\u003e unit = \"\";\n[@bs.module \"react\"]\nexternal useLayoutEffectWithoutCleanup: (unit =\u003e unit) =\u003e unit = \"\";\n\n[@bs.module \"react\"] external useCallback: (unit =\u003e 'a, 'b, unit) =\u003e 'a = \"\";\n[@bs.module \"react\"] external useMemo: (unit =\u003e 'a, 'b) =\u003e 'a = \"\";\n\n[@bs.module \"react\"] external useRef: 'a =\u003e {. \"current\": 'a} = \"\";\n[@bs.module \"react\"]\nexternal useDomRef: unit =\u003e {. \"current\": option(Dom.node)} = \"useRef\";\n\n[@bs.module \"react\"]\nexternal useReducer:\n  (~reducer: (. 'state, 'action) =\u003e 'state, ~initial: 'state) =\u003e\n  ('state, (. 'action) =\u003e unit) =\n  \"\";\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fhooks-experimental","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaredly%2Fhooks-experimental","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaredly%2Fhooks-experimental/lists"}