{"id":13429564,"url":"https://github.com/kalcifer/react-powerhooks","last_synced_at":"2025-03-16T03:31:50.937Z","repository":{"id":34147578,"uuid":"154973588","full_name":"kalcifer/react-powerhooks","owner":"kalcifer","description":"Hooks api for react-powerplug components","archived":false,"fork":false,"pushed_at":"2022-12-09T19:48:04.000Z","size":828,"stargazers_count":100,"open_issues_count":19,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-27T07:32:29.724Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kalcifer.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":"2018-10-27T14:28:47.000Z","updated_at":"2023-09-08T17:46:34.000Z","dependencies_parsed_at":"2023-01-15T05:00:53.338Z","dependency_job_id":null,"html_url":"https://github.com/kalcifer/react-powerhooks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalcifer%2Freact-powerhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalcifer%2Freact-powerhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalcifer%2Freact-powerhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kalcifer%2Freact-powerhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kalcifer","download_url":"https://codeload.github.com/kalcifer/react-powerhooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243822309,"owners_count":20353496,"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-07-31T02:00:41.734Z","updated_at":"2025-03-16T03:31:50.585Z","avatar_url":"https://github.com/kalcifer.png","language":"JavaScript","funding_links":[],"categories":["Packages"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"/hook.png\" height=\"40px\" alt=\"React PowerHooks\" /\u003e\n  \u003cspan fontSize='20px'\u003e react-powerhooks \u003c/span\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003e ⚠️ Warning: hooks are not part of a stable React release yet, so use this library only for experiments\n\n### Demo\n\n[![Edit react-powerhooks example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/j31y1l90m3)\n\n### Install\n\n```bash\nyarn add react-powerhooks\n```\n\n### About\n\n`react-powerhooks` is a set of [react custom-hooks](https://reactjs.org/docs/hooks-custom.html) equivalent to the render props components in [`react-powerplug`](https://github.com/renatorib/react-powerplug)\nHeavily inspired by [`react-hangers`](https://github.com/kitze/react-hanger)\nThe logo is from [wikimedia commons](https://commons.wikimedia.org/wiki/File:OCR_hook.svg)\n\n### API\n\n#### useToggle\n\nThis is a hook that lets you toggle between boolean values.\nIt needs an `initialValue` to work with.\n\n_Usage_\n\n```jsx\nconst initialValue = true;\nconst [currentValue, toggleAway] = useToggle(initialValue);\n```\n\n#### useActive\n\nThis hook lets you know when your mouse pointer is active on a particular element.\nIt needs a `ref` of the element in question to work with. It can also take an `onChange` callback which it calls everytime the active state changes. The `onChange` function recieves the current active state of the element as a boolean value.\n\n_Usage_\n\n```jsx\nconst ref = useRef(null); // Use the ref in the element concerned.\n// More about useRef here https://reactjs.org/docs/hooks-reference.html#useref\nconst activeValue = useActive({ refEl: ref });\n```\n\n#### useInterval\n\nThis hook starts an interval timer that can be stopped/resumed any time.\nIt takes in `startImmediate` which decides whether the interval is on by default.\nIt also takes a `time` which is the interval duration.\n\nIt provides a `start` and `stop` method which allow us to control the state of the interval.\n\n_Usage_\n\n```jsx\nconst [time, setTime] = useState(null);\nconst { start, stop } = useInterval({\n  duration: 1000,\n  startImmediate: false,\n  callback: () =\u003e {\n    setTime(new Date().toLocaleTimeString());\n  }\n});\n\nreturn (\n  \u003cFragment\u003e\n    \u003cdiv\u003eThe time is now {time}\u003c/div\u003e\n    \u003cbutton onClick={() =\u003e stop()}\u003eStop interval\u003c/button\u003e\n    \u003cbutton onClick={() =\u003e start()}\u003eStart interval\u003c/button\u003e\n  \u003c/Fragment\u003e\n);\n```\n\n#### useMap\n\nThis hook allows you to use a map object and get methods to manipulate the map.\nTakes an `initialValue`\n\n_Usage_\n\n```jsx\nconst {\n  set: setKey,\n  get: getKey,\n  has,\n  delete: deleteKey,\n  clear,\n  reset,\n  values\n} = useMap({ name: \"PK\", age: \"30\", occupation: \"Reactor\" });\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalcifer%2Freact-powerhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkalcifer%2Freact-powerhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkalcifer%2Freact-powerhooks/lists"}