{"id":16807772,"url":"https://github.com/lfscamargo/react-lifecycle-hooks","last_synced_at":"2026-07-22T10:31:33.949Z","repository":{"id":96705114,"uuid":"298508450","full_name":"LFSCamargo/react-lifecycle-hooks","owner":"LFSCamargo","description":"A Simple lifecycle abstraction to useEffect to reply lifecycle","archived":false,"fork":false,"pushed_at":"2020-10-04T01:55:05.000Z","size":113,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-20T09:47:07.404Z","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/LFSCamargo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-25T08:04:09.000Z","updated_at":"2022-01-31T12:18:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"d02f7c66-6597-4ccb-956b-08ac51801233","html_url":"https://github.com/LFSCamargo/react-lifecycle-hooks","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/LFSCamargo/react-lifecycle-hooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LFSCamargo%2Freact-lifecycle-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LFSCamargo%2Freact-lifecycle-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LFSCamargo%2Freact-lifecycle-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LFSCamargo%2Freact-lifecycle-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LFSCamargo","download_url":"https://codeload.github.com/LFSCamargo/react-lifecycle-hooks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LFSCamargo%2Freact-lifecycle-hooks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35759166,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-10-13T09:54:57.351Z","updated_at":"2026-07-22T10:31:33.938Z","avatar_url":"https://github.com/LFSCamargo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ccenter\u003e\u003cimg style=\"border-radius: 50%\" src=\"https://raw.githubusercontent.com/alDuncanson/react-hooks-snippets/master/icon.png\" width=\"200px\" height=\"200px\" /\u003e\u003c/center\u003e\n\n# React Lifecycle Hooks\n\nA Simple abstraction to useEffect and make the lifecycle using hooks more declarative\n\n# Motivation\n\nI was coding with some newbie developers, and when i started with the new team i realized that people are getting stuck using the react lifecycle with the `useEffect` hook, so i replicated the methods using the useEffect hook.\n\n# Documentation\n\n## Use Update\n\nThe `useUnmount` hook replicates the same functionality as the `componentDidUpdate` heres an example bellow\n\n```tsx\nimport React from 'react';\nimport { useUpdate } from 'react-lifecycle-hooks';\n\ninterface Props {\n  // your prop interface fields goes here...\n}\n\nconst App = (props: Props) =\u003e {\n  useUpdate((prevProps, nextProps) =\u003e {\n    // place here the code for the update on the component\n  }, props);\n};\n```\n\n### Params:\n\n```tsx\n - `fn`: () =\u003e Promise\u003cvoid\u003e | void\n\n - `props`: Receives a generic called props `\u003cT extends Record\u003cstring, any\u003e\u003e`\n```\n\n## Use Unmount\n\nThe `useUnmount` hook replicates the same functionality as the `componentWillUnmount` heres an example bellow\n\n```tsx\nimport React from 'react';\nimport { useUnmount } from 'react-lifecycle-hooks';\n\nconst App = () =\u003e {\n  useUnmount(async () =\u003e {\n    // place your code bellow\n  });\n};\n```\n\n### Params:\n\n```tsx\n - `fn`: () =\u003e void\n```\n\n## Use Mount\n\nThe `useMount` hook replicates the same functionality as the `componentDidMount` heres an example bellow\n\n```tsx\nimport React from 'react';\nimport { useMount } from 'react-lifecycle-hooks';\n\nconst App = () =\u003e {\n  useMount(async () =\u003e {\n    // place your code bellow\n  });\n};\n```\n\n### Params:\n\n```tsx\n - `fn`: () =\u003e Promise\u003cvoid\u003e | void\n```\n\n## Use Previous\n\nThis is a helper that i've created to replicate the `componentDidUpdate` that gets the last value for that property. i think that will be very useful for you also\n\n```tsx\nimport React, { useState } from 'react';\nimport { usePrevious } from 'react-lifecycle-hooks';\n\nconst App = () =\u003e {\n  const [value] = useState('');\n\n  const previousValue = usePrevious(value) || '';\n};\n```\n\n### Params:\n\n```md\n- `value`: Its a Generic Type for the `value` it already infers the type\n```\n\n### Returns:\n\nThe return will be undefined or the infered value (the type of the variable that you are passing as a parameter).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfscamargo%2Freact-lifecycle-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flfscamargo%2Freact-lifecycle-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flfscamargo%2Freact-lifecycle-hooks/lists"}