{"id":17228564,"url":"https://github.com/benadamstyles/reason-pure-component","last_synced_at":"2026-05-16T01:33:18.526Z","repository":{"id":57153857,"uuid":"170340984","full_name":"benadamstyles/reason-pure-component","owner":"benadamstyles","description":"A PureComponent implementation for ReasonReact","archived":false,"fork":false,"pushed_at":"2019-04-14T16:11:13.000Z","size":278,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T18:52:08.576Z","etag":null,"topics":["purecomponent","react","reason","reason-react","reasonml"],"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/benadamstyles.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}},"created_at":"2019-02-12T15:23:41.000Z","updated_at":"2020-04-10T11:00:33.000Z","dependencies_parsed_at":"2022-09-07T12:21:08.543Z","dependency_job_id":null,"html_url":"https://github.com/benadamstyles/reason-pure-component","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/benadamstyles/reason-pure-component","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benadamstyles%2Freason-pure-component","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benadamstyles%2Freason-pure-component/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benadamstyles%2Freason-pure-component/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benadamstyles%2Freason-pure-component/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benadamstyles","download_url":"https://codeload.github.com/benadamstyles/reason-pure-component/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benadamstyles%2Freason-pure-component/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262628184,"owners_count":23339744,"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":["purecomponent","react","reason","reason-react","reasonml"],"created_at":"2024-10-15T04:44:30.092Z","updated_at":"2026-05-16T01:33:13.505Z","avatar_url":"https://github.com/benadamstyles.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reason-pure-component\n\nA PureComponent implementation for ReasonReact. Simplify your `shouldUpdate`!\n\n## Installation\n\n```sh\nnpm install reason-pure-component\n```\n\n**`bsconfig.json`:**\n\n```diff\n\"bs-dependencies\": [\n  \"reason-react\",\n+  \"reason-pure-component\"\n]\n```\n\n## Usage\n\nUsing reason-pure-component doesn't result in fewer lines of code, necessarily. The benefit is in the abstraction of how you compare `oldSelf.retainedProps` and `newSelf.retainedProps`. You simply define an equality function – in this case `==` . Thanks to the OCaml type system, if you forget to define any of the required configuration, the program will not compile – whereas if you use `ReasonReact.statelessComponentWithRetainedProps` directly, and forget to define `shouldUpdate`, no one is any the wiser.\n\n```diff\n+ module Config = {\n    type retainedProps = {\n      view: string,\n      subview: option(string),\n    };\n+   let name = \"Breadcrumb\";\n+   let equals = (==);\n+ };\n\n- let component =\n-    ReasonReact.statelessComponentWithRetainedProps(\n-      \"Breadcrumb\"\n-    );\n\n+ module Pure = PureComponent.Stateless(Config);\n\nlet make = (~view, ~subview=?, _children) =\u003e {\n-  ...component,\n+  ...Pure.component,\n\n-  retainedProps: {view, subview},\n+  retainedProps: Config.{view, subview},\n\n-  shouldUpdate: (oldAndNewSelf) =\u003e\n-    oldAndNewSelf.oldSelf.retainedProps !=\n-    oldAndNewSelf.newSelf.retainedProps,\n\n  render: _ =\u003e\n    \u003cdiv\u003e\n      \u003cp\u003e{ReasonReact.string(view)}\u003c/p\u003e\n      \u003cp\u003e\n        {ReasonReact.string(\n          subview-\u003eBelt.Option.getWithDefault(\"\")\n        )}\n      \u003c/p\u003e\n    \u003c/div\u003e,\n};\n```\n\n## Known issues\n\n### [genType](https://github.com/cristianoc/genType) compatibility\n\n**genType** assumes your component exports its `component` record. Therefore, in the above example, you need to add the following line:\n\n```reason\nlet component = Pure.component;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenadamstyles%2Freason-pure-component","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenadamstyles%2Freason-pure-component","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenadamstyles%2Freason-pure-component/lists"}