{"name":"use-latest-callback","version":"0.2.5","keywords":["react","use-event","use-callback"],"author":{"name":"Satyajit Sahoo","email":"satyajit.happy@gmail.com"},"license":"MIT","_id":"use-latest-callback@0.2.5","maintainers":[{"name":"satya164","email":"satyajit.happy@gmail.com"}],"homepage":"https://github.com/satya164/use-latest-callback#readme","bugs":{"url":"https://github.com/satya164/use-latest-callback/issues"},"dist":{"shasum":"72a36d17ba6948f923d27ebf05a5c415d61a4b2f","tarball":"http://registry-npm.ywwl.com/use-latest-callback/download/use-latest-callback-0.2.5.tgz","fileCount":7,"integrity":"sha512-TXEBT/M2zOFrS7t3EpxZIaYsEVod34ctrq2gDDV6Dr1KfFIy+sA++5KKpu2AkM3iIFqopPGe5C3IMQk6yqFFWw==","signatures":[{"sig":"MEUCIQCGgpEtfe11JKOy+ob258tVkNUVcolOsanI7slvnhZc8gIgA/EU860fB8k+87DPhvtA6XRFvg4Y6KCm6BtZ8UZpkOY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/use-latest-callback@0.2.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6353,"size":2730,"noattachment":false,"key":"/use-latest-callback/-/use-latest-callback-0.2.5.tgz"},"main":"./lib/src/index.js","type":"commonjs","types":"./lib/src/index.d.ts","source":"./src/index.ts","exports":{".":{"types":"./lib/src/index.d.ts","import":"./esm.mjs","default":"./lib/src/index.js"}},"gitHead":"506abead60123fa8992c19bb694604e2ab3efa6d","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"node --test","build":"tsc --declaration","prepare":"yarn build","release":"release-it","prebuild":"del lib","typecheck":"tsc --noEmit"},"_npmUser":{"name":"satya164","email":"satyajit.happy@gmail.com"},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"infile":"CHANGELOG.md","preset":{"name":"conventionalcommits"}}}},"repository":{"url":"git+https://github.com/satya164/use-latest-callback.git","type":"git"},"_npmVersion":"10.8.2","description":"React hook which returns the latest callback without changing the reference","directories":{},"_nodeVersion":"18.20.8","eslintConfig":{"env":{"node":true,"browser":true},"rules":{"import/no-commonjs":"off"},"extends":"satya164"},"eslintIgnore":["node_modules/","lib/"],"publishConfig":{"registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"react":"^17.0.2","eslint":"^8.53.0","del-cli":"^4.0.1","prettier":"^3.0.3","commitlint":"^12.1.4","release-it":"^16.2.1","typescript":"^5.2.2","@types/react":"^18.0.10","eslint-config-satya164":"^3.2.0","@commitlint/config-conventional":"^12.1.4","@release-it/conventional-changelog":"^7.0.2"},"peerDependencies":{"react":">=16.8"},"_npmOperationalInternal":{"tmp":"tmp/use-latest-callback_0.2.5_1759737886496_0.6423991365432331","host":"s3://npm-registry-packages-npm-production"},"readme":"# use-latest-callback\n\nReact hook which returns the latest callback without changing the reference.\n\nThis is useful for scenarios such as event listeners where you may not want to resubscribe when the callback changes.\n\n## Installation\n\nOpen a Terminal in the project root and run:\n\n```sh\nnpm install use-latest-callback\n```\n\n## Usage\n\nThe `useLatestCallback` hook accepts a function as its argument and returns a function that preserves its reference across renders.\n\n```js\nimport useLatestCallback from 'use-latest-callback';\n\n// ...\n\nfunction MyComponent() {\n  const callback = useLatestCallback((value) => {\n    console.log('Changed', value);\n  });\n\n  React.useEffect(() => {\n    someEvent.addListener(callback);\n\n    return () => someEvent.removeListener(callback);\n  }, [callback]);\n\n  return <>{/* whatever */}</>;\n}\n```\n\nIt's important to note that the callback is not intended to be called during the render phase. Only call the callback in response to an event.\n","publish_time":1759737886662,"_cnpm_publish_time":1759737886662,"dist-tags":{"latest":"0.3.5"}}