{"id":18585649,"url":"https://github.com/joakimunge/react-use-lifecycle","last_synced_at":"2026-04-29T00:05:53.135Z","repository":{"id":115909467,"uuid":"304017277","full_name":"joakimunge/react-use-lifecycle","owner":"joakimunge","description":"Hooks implementation of common react class component lifecycle methods","archived":false,"fork":false,"pushed_at":"2020-10-14T13:18:14.000Z","size":3,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-17T17:53:10.883Z","etag":null,"topics":["fire","hooks","lifecycle","lifecycle-hooks","lifecycle-methods","react"],"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/joakimunge.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":"2020-10-14T13:04:35.000Z","updated_at":"2021-02-02T19:27:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f2b1583-d716-4db6-8c87-3e17b127a586","html_url":"https://github.com/joakimunge/react-use-lifecycle","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/joakimunge%2Freact-use-lifecycle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Freact-use-lifecycle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Freact-use-lifecycle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joakimunge%2Freact-use-lifecycle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joakimunge","download_url":"https://codeload.github.com/joakimunge/react-use-lifecycle/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478189,"owners_count":22077677,"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":["fire","hooks","lifecycle","lifecycle-hooks","lifecycle-methods","react"],"created_at":"2024-11-07T00:34:58.603Z","updated_at":"2026-04-29T00:05:53.106Z","avatar_url":"https://github.com/joakimunge.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React Lifecycle Hooks\n\n\u003e Hooks implementation of common react lifecycle methods.\n\n## Install\n\n```\n$ npm install react-lifecycle-hooks\n```\n\n## Usage\n\n```js\nimport {\n  useComponentDidMount,\n  useComponentDidUpdate,\n  useComponentWillUnmount,\n} from 'react-lifecycle-hooks';\n\nconst SomeComponent = () =\u003e {\n  useComponentDidMount(() =\u003e {\n    // Your effect that will fire once\n  });\n\n  useComponentDidUpdate(() =\u003e {\n    // Your effect\n  });\n\n  useComponentWillUnmount(() =\u003e {\n    // Your effect\n  });\n};\n```\n\nJust like with a regular `useEffect` you can pass guards/dependencies to `useComponentDidUpdate` to make it fire only when those dependencies has been updated.\n\n```js\nconst SomeComponent = () =\u003e {\n  useComponentDidUpdate(() =\u003e {\n    // Your effect that only fires when someProp is updated\n  }, [someProp]);\n};\n```\n\n## Reasoning\n\nI like readable code. I like react. What I don't like is the somewhat convoluted code that comes with implementing lifecycle methods with `useEffect`. For example, returning a function in the end of an effect never screamed \"This will be fired before the component unmounts\" to me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimunge%2Freact-use-lifecycle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoakimunge%2Freact-use-lifecycle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoakimunge%2Freact-use-lifecycle/lists"}