imbhargav5 / rooks

Essential React custom hooks ⚓ to super charge your components!
https://rooks.vercel.app
MIT License
3.19k stars 216 forks source link

feat: add `useCallOnce` hook #1750

Closed AbdUlHamedMaree closed 2 months ago

AbdUlHamedMaree commented 4 months ago

Adding useCallOnce hook

Call the passed function once in the component lifecycle,

unlike useMemo that even when you pass empty deps it might call your callback again (check last sentence in react docs),

that's why some libraries use useState to call function once in the component lifecycle

codesandbox[bot] commented 4 months ago

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders
Open Preview

vercel[bot] commented 4 months ago

@AbdUlHamedMaree is attempting to deploy a commit to the Rooks Team on Vercel.

A member of the Team first needs to authorize it.

stale[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.