{"id":15042032,"url":"https://github.com/discord/react-base-hooks","last_synced_at":"2026-03-27T01:54:59.797Z","repository":{"id":46925026,"uuid":"201517358","full_name":"discord/react-base-hooks","owner":"discord","description":"Basic utility React hooks","archived":false,"fork":false,"pushed_at":"2023-07-11T01:07:13.000Z","size":159,"stargazers_count":76,"open_issues_count":15,"forks_count":12,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-10-20T01:16:02.503Z","etag":null,"topics":["hooks","react"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/discord.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-09T18:01:08.000Z","updated_at":"2025-06-02T17:07:11.000Z","dependencies_parsed_at":"2024-09-25T01:39:28.423Z","dependency_job_id":"e17b658a-8a01-4752-9657-e627c090f9f6","html_url":"https://github.com/discord/react-base-hooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/discord/react-base-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Freact-base-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Freact-base-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Freact-base-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Freact-base-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/discord","download_url":"https://codeload.github.com/discord/react-base-hooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/discord%2Freact-base-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31008374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T01:50:43.500Z","status":"ssl_error","status_checked_at":"2026-03-27T01:50:41.231Z","response_time":114,"last_error":"SSL_read: 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","react"],"created_at":"2024-09-24T20:46:46.416Z","updated_at":"2026-03-27T01:54:59.777Z","avatar_url":"https://github.com/discord.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-base-hooks\n\nThis is a collection of basic React hooks that are an extension of the React core library.\n\n#### Installation\n\n```\nnpm install react-base-hooks\n```\n\n## useLazyValue\n\n`useLazyValue` calls the provided factory on mount and returns this value for the duration of the component's lifecycle. See React docs on [creating expensive objects lazily](https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily).\n\n```js\nimport {useLazyValue} from 'react-base-hooks';\nfunction MyComponent() {\n  const animatedValue = useLazyValue(() =\u003e new Animated.Value());\n  ...\n}\n```\n\nAnother common use case is creating a debounced handler.\n\n```js\nfunction MyComponent() {\n  const onScroll = useLazyValue(() =\u003e {\n    return debounce(() =\u003e console.log('debounced scroll'), 1000);\n  });\n  ...\n}\n```\n\n#### Comparison to useMemo\n\nYou cannot rely on `useMemo` as [a semantic guarantee](https://reactjs.org/docs/hooks-reference.html#usememo). React may throw away the cached value and recall your factory even if deps did not change.\n\n#### Comparison to useState\n\nYou can get the same result using `useState(factory)[0]`, but it's a little more expensive supporting unused update functionality.\n\n#### Comparison to useRef\nYou can implement this yourself as described in React doc's [how to create expensive objects lazily](https://reactjs.org/docs/hooks-faq.html#how-to-create-expensive-objects-lazily). However, `useLazyValue` is likely more convenient and hides the `ref.current` implementation detail.\n\n## useForceUpdate\n\nProvides the same functionality as `forceUpdate` in React class components. Useful when your component relies on data outside React's purview (external data or refs).\n\n```js\nimport {useForceUpdate} from 'react-base-hooks';\nfunction MyComponent() {\n  const forceUpdate = useForceUpdate();\n  useEffect(() =\u003e DataStore.subscribe(() =\u003e forceUpdate()), []);\n  return \u003cdiv\u003e{DataStore.data}\u003c/div\u003e;\n}\n```\n\n## useStableMemo\n\nJust like `useMemo` but is guaranteed to return the same value if provided deps don't change.\n\n```js\nimport {useStableMemo} from 'react-base-hooks';\nfunction MyComponent({input}) {\n  const instance = useStableMemo(() =\u003e createInstance(input), [input]);\n  ...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Freact-base-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiscord%2Freact-base-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiscord%2Freact-base-hooks/lists"}