{"id":13726686,"url":"https://github.com/Astrocoders/recontainers","last_synced_at":"2025-05-07T22:30:27.954Z","repository":{"id":98965653,"uuid":"141604053","full_name":"Astrocoders/recontainers","owner":"Astrocoders","description":"[DEPRECATED] ReasonReact utilitary high order components","archived":true,"fork":false,"pushed_at":"2020-07-16T21:03:46.000Z","size":340,"stargazers_count":54,"open_issues_count":10,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-05T02:02:04.005Z","etag":null,"topics":["react","reason-react","reasonml"],"latest_commit_sha":null,"homepage":"","language":"Reason","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/Astrocoders.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-07-19T16:16:27.000Z","updated_at":"2023-01-28T13:18:53.000Z","dependencies_parsed_at":"2023-07-07T14:46:14.717Z","dependency_job_id":null,"html_url":"https://github.com/Astrocoders/recontainers","commit_stats":{"total_commits":31,"total_committers":3,"mean_commits":"10.333333333333334","dds":0.06451612903225812,"last_synced_commit":"cf452908555a2c54d56713f2301af438574f2817"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrocoders%2Frecontainers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrocoders%2Frecontainers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrocoders%2Frecontainers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Astrocoders%2Frecontainers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Astrocoders","download_url":"https://codeload.github.com/Astrocoders/recontainers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252965069,"owners_count":21832817,"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":["react","reason-react","reasonml"],"created_at":"2024-08-03T01:03:16.682Z","updated_at":"2025-05-07T22:30:27.639Z","avatar_url":"https://github.com/Astrocoders.png","language":"Reason","funding_links":[],"categories":["Reason"],"sub_categories":[],"readme":"# [We strongly suggest for you to use hooks now](https://reasonml.github.io/reason-react/docs/en/components)\n\n\n# ReContainers\n\n[![Build Status](https://travis-ci.org/Astrocoders/ReContainers.svg?branch=master)](https://travis-ci.org/Astrocoders/ReContainers)\n\nType safe high order components for ReasonReact\n\n```\n$ yarn add re-containers\n```\n\n## Inspired by\n\nInspired by [recompose](https://github.com/acdlite/recompose/), [react-powerplug](https://github.com/renatorib/react-powerplug) and [smalldots](https://github.com/smalldots)\n\n# Containers\n\nAvailable API\n\n## Recommended usage\nComposing Render Props is not an easy tasks, that's why we created https://github.com/Astrocoders/bs-epitath to offer a easy syntax do compose your Render Props in an await-async manner.\n\n```ocaml\nlet%Epitath myState = c =\u003e \u003cWithState\u003e ...c \u003c/WithState\u003e;\nlet%Epitath mutate = c =\u003e \u003cMutationContainer\u003e ...c \u003c/MutationContainer\u003e;\n\nmyState.send(foo)\n```\n\n[We recommend you reading this article to get started](https://medium.com/astrocoders/render-props-composition-for-reasonml-is-here-b9c004ca9fcb)\n\n## WithState\n\n```ocaml\nmodule WithState = ReContainers.WithState.Make({\n  type state = int;\n});\n\n\u003cdiv\u003e\n  \u003cWithState initialState=0\u003e\n    ...(({ state, send }) =\u003e {\n      \u003cdiv\u003e\n        \u003cp\u003eReasonReact.string(\"Count is \" ++ string_of_int(state))\u003c/p\u003e\n        \u003cbutton onClick=((_) =\u003e send(Set(state + 1)))\u003e(ReasonReact.string(\"+\"))\u003c/button\u003e\n        \u003cbutton onClick=((_) =\u003e send(Set(state - 1)))\u003e(ReasonReact.string(\"+\"))\u003c/button\u003e\n      \u003c/div\u003e\n    })\n  \u003c/WithState\u003e\n\u003c/div\u003e\n```\n\n## Component\n\nNice for lifecycle helpers\n\n```ocaml\n\u003cComponent didMount willUnmount willUpdate\u003e\n  ...((self) =\u003e {\n    \u003cdiv /\u003e\n  })\n\u003c/Component\u003e\n```\n\n## Loader\n\nHandling promises\n\n```ocaml\nmodule ReLoader = ReContainers.Loader.Make({\n  /* Promise result */\n  type t = int;\n});\n```\n\n```ocaml\n/* Could be a fetch for instance */\nlet makeTimeout = () =\u003e\n  Js.Promise.make((~resolve, ~reject as _) =\u003e\n    Js.Global.setTimeout(() =\u003e resolve(. 0), 2000) |\u003e ignore\n  );\n\n\u003cReLoader\u003e\n  ...(\n       ({state, load}) =\u003e\n         \u003cdiv className=\"App\"\u003e\n           \u003cdiv className=\"App-header\"\u003e\n             \u003cimg src=logo className=\"App-logo\" alt=\"logo\" /\u003e\n             \u003ch2\u003e (ReasonReact.string(message)) \u003c/h2\u003e\n             \u003cbutton onClick=(_e =\u003e load(makeTimeout()))\u003e\n               (ReasonReact.string(\"Click me\"))\n             \u003c/button\u003e\n           \u003c/div\u003e\n           (\n             switch (state) {\n             | Loading =\u003e\n               \u003cp\u003e (ReasonReact.string(\"Hang a sec\")) \u003c/p\u003e\n             | Error(string) =\u003e \u003cp\u003e (ReasonReact.string(string)) \u003c/p\u003e\n             | Success(_promiseResult) =\u003e \u003cp\u003e (ReasonReact.string(\"All good\")) \u003c/p\u003e\n             | Empty =\u003e ReasonReact.null\n             }\n           )\n         \u003c/div\u003e\n     )\n\u003c/ReLoader\u003e\n```\n\n## ReList\n\nIt manages the state of lists for you\n\nMake\n\n```ocaml\nmodule ReList = ReContainers.ReList.Make({\n  type t = { name: string, age: int };\n});\n```\n\nUsage\n\n```ocaml\n\u003cReList initial=[{ name: \"Dio Brando\", age: 123 }]\u003e\n  ...(({ list, pull, push }) =\u003e (\n    \u003cWrapper\u003e\n      \u003cCharFormInput onSubmit=(({ values }) =\u003e push(values)) /\u003e\n\n      (\n        list\n        |\u003e List.map(todo =\u003e (\n          \u003cCharItem onDelete=pull(({ age, name }) =\u003e char.name == name \u0026\u0026 char.age == age)\u003e\n            (ReasonReact.string(char.name))\n          \u003c/CharItem\u003e\n        ))\n        |\u003e Array.of_list\n        |\u003e ReasonReact.array\n      )\n    \u003c/Wrapper\u003e\n  ))\n\u003c/ReList\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAstrocoders%2Frecontainers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAstrocoders%2Frecontainers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAstrocoders%2Frecontainers/lists"}