{"id":18336331,"url":"https://github.com/launchpadlab/lp-hoc","last_synced_at":"2025-04-13T07:49:33.397Z","repository":{"id":25803247,"uuid":"106595962","full_name":"LaunchPadLab/lp-hoc","owner":"LaunchPadLab","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-03T17:41:41.000Z","size":1006,"stargazers_count":1,"open_issues_count":13,"forks_count":0,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-11T00:45:32.911Z","etag":null,"topics":[],"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/LaunchPadLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-10-11T18:51:59.000Z","updated_at":"2022-06-14T15:21:45.000Z","dependencies_parsed_at":"2024-11-05T20:11:15.293Z","dependency_job_id":null,"html_url":"https://github.com/LaunchPadLab/lp-hoc","commit_stats":{"total_commits":69,"total_committers":7,"mean_commits":9.857142857142858,"dds":0.2753623188405797,"last_synced_commit":"f152d6ef9ae2826f1894765cbba03d1cd9aa37be"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPadLab%2Flp-hoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPadLab%2Flp-hoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPadLab%2Flp-hoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LaunchPadLab%2Flp-hoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LaunchPadLab","download_url":"https://codeload.github.com/LaunchPadLab/lp-hoc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248681494,"owners_count":21144700,"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-05T20:07:33.296Z","updated_at":"2025-04-13T07:49:33.366Z","avatar_url":"https://github.com/LaunchPadLab.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/%40launchpadlab%2Flp-hoc.svg)](https://badge.fury.io/js/%40launchpadlab%2Flp-hoc)\n\n# lp-hoc\n\nA set of React higher order components (HOCs).\n\nHigher order components _wrap_ components to give them extra functionality. For instance, defining a callback to be triggered when a component mounts:\n\n```jsx\nimport { onMount } from '@launchpadlab/lp-hoc'\n\nfunction MyComponent() {\n  return \u003cdiv\u003eI'm a component\u003c/div\u003e\n}\n\nfunction myMountFunction(props) {\n  // will be called when component mounts\n}\n\nexport default onMount(myMountFunction)(MyComponent)\n```\n\nHOCs allow you to replicate the functionality of class-based components using functional components. The HOCs in this library can be combined with those from [recompose](https://github.com/acdlite/recompose/blob/master/docs/API.md)- in fact, you can think of this library as an extension to that one.\n\nA list of all available HOCs can be found in the [documentation](#documentaiton).\n\n## A note about hooks\n\nThe use case of HOCs has been largely addressed by the addition of [React hooks](https://reactjs.org/docs/hooks-overview.html) in v16.8. If possible, we recommend you use hooks instead of HOCs when building new components.\n\nHere's a handy reference for determining which hooks solve for the use-cases of `lp-hoc` components (corresponding `recompose` components in parentheses):\n\n1. `getSet` (`withState`) -\u003e `useState`\n1. `modifyProps` (`withProps`) -\u003e `useMemo` and `useCallback`\n1. `onMount` -\u003e `useEffect`\n1. `onUnmount` -\u003e `useEffect`\n1. `onUpdate` -\u003e `useEffect`\n1. `waitFor` -\u003e if statements\n\n## Documentation\n\nDocumentation and usage info can be found in [docs.md](docs.md).\n\n## Migration Guides\n\n- [From lp-utils](migration-guides/from-lp-utils.md)\n- [v2.0.0](migration-guides/v2.0.0.md)\n- [v3.0.0](migration-guides/v3.0.0.md)\n- [v4.0.0](migration-guides/v4.0.0.md)\n- [v5.0.0](migration-guides/v5.0.0.md)\n\n## Contribution\n\nThis package follows the Opex [NPM package guidelines](https://github.com/LaunchPadLab/opex/blob/master/gists/npm-package-guidelines.md). Please refer to the linked document for information on contributing, testing and versioning.\n\n## Additional info\n\n#### Cherry-picking imports\n\nAlong with ES module support, this library supports cherry-picked imports from the `lib` folder to reduce bundle sizes:\n\n```js\nimport onUpdate from '@launchpadlab/lp-hoc/lib/onUpdate'\nimport onMount from '@launchpadlab/lp-hoc/lib/onMount'\n```\n\nYou can also combine this feature with [babel-plugin-transform-imports](https://www.npmjs.com/package/babel-plugin-transform-imports) to cherry-pick imports by default:\n\n```js\n// .babelrc\n{\n    \"plugins\": [\n        [\"transform-imports\", {\n            \"@launchpadlab/lp-hoc\": {\n                \"transform\": \"@launchpadlab/lp-hoc/lib/${member}\",\n                \"preventFullImport\": true\n            }\n        }]\n    ]\n}\n```\n\n#### Size Limit\n\nThis library uses [size-limit](https://github.com/ai/size-limit) to prevent size bloat. The `yarn size` script is run in CI to check that the package size is under the limit specified in [.size-limit.js](.size-limit.js). For a visualization of this package's relative dependency sizes, you can run `yarn size --why`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchpadlab%2Flp-hoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaunchpadlab%2Flp-hoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaunchpadlab%2Flp-hoc/lists"}