{"id":13450633,"url":"https://github.com/awmleer/use-action","last_synced_at":"2025-07-25T17:10:35.730Z","repository":{"id":34932620,"uuid":"192291498","full_name":"awmleer/use-action","owner":"awmleer","description":"Almost same to useEffect, but not deferred.","archived":false,"fork":false,"pushed_at":"2022-12-03T13:59:21.000Z","size":404,"stargazers_count":15,"open_issues_count":10,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T13:02:30.744Z","etag":null,"topics":["action","effect","hook","react"],"latest_commit_sha":null,"homepage":null,"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/awmleer.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}},"created_at":"2019-06-17T06:55:45.000Z","updated_at":"2023-03-12T09:02:51.000Z","dependencies_parsed_at":"2023-01-15T10:45:20.527Z","dependency_job_id":null,"html_url":"https://github.com/awmleer/use-action","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awmleer%2Fuse-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awmleer%2Fuse-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awmleer%2Fuse-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awmleer%2Fuse-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awmleer","download_url":"https://codeload.github.com/awmleer/use-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244250095,"owners_count":20423091,"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":["action","effect","hook","react"],"created_at":"2024-07-31T07:00:36.848Z","updated_at":"2025-03-22T04:30:27.885Z","avatar_url":"https://github.com/awmleer.png","language":"TypeScript","funding_links":[],"categories":["Packages","TypeScript"],"sub_categories":[],"readme":"# useAction\n\nAlmost same to useEffect, but not deferred.\n\n## Why `useAction`?\n\n\u003e Unlike componentDidMount and componentDidUpdate, the function passed to useEffect fires after layout and paint, during a deferred event. This makes it suitable for the many common side effects, like setting up subscriptions and event handlers, because most types of work shouldn’t block the browser from updating the screen.\n\nFrom [React docs](https://reactjs.org/docs/hooks-reference.html#timing-of-effects).\n\nBut `useAction` can execute the action function immediately after `useAction` get called.\n\n## Example\n\n### useEffect\n\n```jsx\nfunction Foo(props) {\n  ref = useRef(null)\n  useEffect(() =\u003e {\n    ref.current = 'initialized'\n  }, [])\n  console.log(ref.current) // -\u003e null\n  return null\n}\n```\n\n### useAction\n\n```jsx\nfunction Foo(props) {\n  ref = useRef(null)\n  useAction(() =\u003e {\n    ref.current = 'initialized'\n  }, [])\n  console.log(ref.current) // -\u003e initialized\n  return null\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawmleer%2Fuse-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawmleer%2Fuse-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawmleer%2Fuse-action/lists"}