{"id":21890743,"url":"https://github.com/chantastic/use-lodash","last_synced_at":"2025-09-10T00:15:57.331Z","repository":{"id":57388189,"uuid":"155290745","full_name":"chantastic/use-lodash","owner":"chantastic","description":"A really terrible React Hook that is illustrative in other ways","archived":false,"fork":false,"pushed_at":"2018-10-29T22:50:47.000Z","size":3,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-01T05:04:51.523Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/chantastic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-29T22:39:43.000Z","updated_at":"2021-10-24T18:49:42.000Z","dependencies_parsed_at":"2022-09-26T16:50:41.917Z","dependency_job_id":null,"html_url":"https://github.com/chantastic/use-lodash","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chantastic/use-lodash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chantastic%2Fuse-lodash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chantastic%2Fuse-lodash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chantastic%2Fuse-lodash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chantastic%2Fuse-lodash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chantastic","download_url":"https://codeload.github.com/chantastic/use-lodash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chantastic%2Fuse-lodash/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266285462,"owners_count":23905355,"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-11-28T12:16:39.492Z","updated_at":"2025-07-21T10:32:45.974Z","avatar_url":"https://github.com/chantastic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# use-lodash\nA really terrible React Hook that is illustrative in other ways\n\n## Don't use this\nThis is a terrible idea for so many reasons.  \nBut it's an instructive way to think about custom state Hooks.\n\n## Play\n\nhttps://codesandbox.io/s/011jx4nyql\n\n## Implementation\n\n```jsx\nimport React, { useState } from \"react\";\nimport lodash from \"lodash\";\n\nfunction useLodash(initialSubject) {\n  let [subject, updateSubject] = useState(initialSubject);\n\n  let updaters = {};\n\n  Object.keys(lodash.prototype).forEach(\n    name =\u003e\n      (updaters[name] = (...args) =\u003e\n        updateSubject(lodash[name](subject, ...args)))\n  );\n\n  return {\n    subject,\n    ...updaters\n  };\n}\n```\n\n## Usage\n\nYou can use any function here: https://lodash.com/docs/4.17.10\n\nExample:\n\n```jsx\nimport ReactDOM from \"react-dom\";\n\nfunction App() {\n  let { subject: list, concat, without } = useLodash([\"one\", \"two\", \"three\"]);\n  return (\n    \u003cul\u003e\n      {list.map(item =\u003e \u003cli key={item}\u003e{item}\u003c/li\u003e)}\n      \u003cbutton type=\"submit\" onClick={() =\u003e concat([\"four\"])}\u003e\n        concat \"four\"\n      \u003c/button\u003e\n      \u003cbutton type=\"submit\" onClick={() =\u003e without(\"two\")}\u003e\n        without \"two\"\n      \u003c/button\u003e\n    \u003c/ul\u003e\n  );\n}\n\nconst rootElement = document.getElementById(\"root\");\nReactDOM.render(\u003cApp /\u003e, rootElement);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchantastic%2Fuse-lodash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchantastic%2Fuse-lodash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchantastic%2Fuse-lodash/lists"}