{"id":16720954,"url":"https://github.com/yoavniran/recoil-spring","last_synced_at":"2026-05-19T17:15:15.165Z","repository":{"id":65001343,"uuid":"574510480","full_name":"yoavniran/recoil-spring","owner":"yoavniran","description":"Jumpstart Recoil - less boilerplate, more fun.","archived":false,"fork":false,"pushed_at":"2023-01-23T09:53:27.000Z","size":875,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-10T18:37:42.803Z","etag":null,"topics":["hooks","reactjs","recoil","state-management"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/yoavniran.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["yoavniran"]}},"created_at":"2022-12-05T13:24:45.000Z","updated_at":"2023-07-04T05:37:15.000Z","dependencies_parsed_at":"2023-02-12T16:46:10.491Z","dependency_job_id":null,"html_url":"https://github.com/yoavniran/recoil-spring","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/yoavniran/recoil-spring","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Frecoil-spring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Frecoil-spring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Frecoil-spring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Frecoil-spring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoavniran","download_url":"https://codeload.github.com/yoavniran/recoil-spring/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoavniran%2Frecoil-spring/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33225529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-19T15:49:41.270Z","status":"ssl_error","status_checked_at":"2026-05-19T15:49:22.917Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["hooks","reactjs","recoil","state-management"],"created_at":"2024-10-12T22:27:36.644Z","updated_at":"2026-05-19T17:15:15.149Z","avatar_url":"https://github.com/yoavniran.png","language":"JavaScript","funding_links":["https://github.com/sponsors/yoavniran"],"categories":[],"sub_categories":[],"readme":"# Recoil:Spring\n\n[![recoil-spring CI](https://github.com/yoavniran/recoil-spring/actions/workflows/recoil-spring-ci.yml/badge.svg)](https://github.com/yoavniran/recoil-spring/actions/workflows/recoil-spring-ci.yml)\n\n\n\n![Recoil:Spring Logo](#gh-dark-mode-only)\n![Recoil:Spring Logo](#gh-light-mode-only)\n\n\u003cp align=\"center\"\u003eJumpstart Recoil - less boilerplate, more fun.\u003c/p\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eContents\u003c/summary\u003e\n\n* [Intro](#intro)\n* [Documentation](#documentation)\n* [Installation](#installation)\n* [Quick Start](#quickstart)\n* [Acknowledgements](#acknowledgements)\n\u003c/details\u003e\n\n## Intro\n\nThink React Toolkit or MobX State Tree but for Recoil. Opinionated but not too much :) \n\n\nno dependencies (beyond peers: React \u0026 Recoil)\n\nTiny !\n\n\n## Documentation\n\nSee docs site - \n\n## Quick Start\n\nThe best place to find details of the Recoil:Spring API is at the doc site mentioned above.\nHowever, this section highlights the main concepts and usage.\n\n### Spring\n\nTwo ways to initialize: Object-map or chained calls.\n\nBoth code examples below are identical in their outcome:\n\n```javascript\n\n```\n\n```javascript\n\n```\n\n\n### Atom Family\n\nOne of Recoil's more useful yet cumbersome entities is the Atom Family. It's extremely useful for storing data over a collection.\nYet, Recoil doesn't provide a way to track the items within the collection. Their docs explain that a custom atom should be employed to do that.\nSpring does this seamlessly when encountering a Family record.\n\n### Selectors\n\n### Simple Selector\n\nBelow is an example of the simplest read/write selector hook \n\n```javascript\nimport { createSelectorHook } from \"recoil-spring\";\nimport atoms from \"../store\";\n\nconst {\n\tborderColor\n} = atoms;\n\nconst useCollageBorderColor = createSelectorHook(borderColor);\n\n//recoil:spring will generate a selector key using the atom's key. \n//If you'd like to set your own key do the following:\nconst useCollageBorderColor = createSelectorHook(\"MyCustomBorderColorSelector\", borderColor);\n\nexport default useCollageBorderColor;\n```\n\n```jsx\nimport useCollageBorderColor from \"./store/selectors/useCollageBorderColor\";\n\nconst MyComponent = () =\u003e {\n  const [borderColor, setBorderColor] = useCollageBorderColor();\n\t\t\n  return (\n\t\t\u003cinput \n          type=\"number\"\n          value={borderColor}\n          onChange={(e) =\u003e setBorderColor(parseInt(e.target.value))}\n        /\u003e\n  );\n};\n```\n\n#### Computed\n\nBelow is an example of a computed selector, combining two atoms into one result: \n\n```javascript\nimport { createSelectorHook } from \"recoil-spring\";\nimport atoms from \"../store\";\n\nconst {\n\tborderWidth,\n\tborderColor,\n} = atoms;\n\nconst useCollageBorder = createSelectorHook(\n\t//need to provide a key for the selector since we use a custom getter\n\t\"CollageBorderSelector\",\n\t(get) =\u003e [get(borderColor), get(borderWidth)],\n);\n\nexport default useCollageBorder;\n```\n\nUsing the resulting readonly selector hook is done in the following way:\n\n```jsx\nimport useCollageBorder from \"./store/selectors/useCollageBorder\";\n\nconst MyComponent = () =\u003e {\n\tconst [color, width] = useCollageBorder();\n\n\treturn (\n\t\t\u003cdiv\n\t\t\tstyle={{ borderColor: color, borderWidth: `${width}px` }}\u003e\n\t\t\t//...\n\t\t\u003c/div\u003e\n    );\n};\n\n```\n\n#### Custom Setter\n\nBelow is a selector hook that reads one (atom) value but writes to two atoms.\nUsing it works exactly the same as any other read/write hook\n\n```javascript\nimport { createSelectorHook } from \"recoil-spring\";\nimport atoms from \"../store\";\n\nconst {\n\twidth,\n\theight,\n} = atoms;\n\nconst useDimensions = createSelectorHook(\n\twidth,\n\t(newVal, { set }) =\u003e {\n\t\tset(width, newVal);\n\t\tset(height, newVal);\n\t},\n);\n\nexport default useDimensions;\n```\n\n\n## Acknowledgements\n\nlogo's spring thanks to: \u003ca href=\"https://www.flaticon.com/free-icons/spring\" title=\"spring icons\"\u003eSpring icons created by Zaenul Yahya - Flaticon\u003c/a\u003e\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoavniran%2Frecoil-spring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoavniran%2Frecoil-spring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoavniran%2Frecoil-spring/lists"}