{"name":"use-latest-callback","version":"0.3.3","keywords":["react","use-event","use-callback"],"author":{"name":"Satyajit Sahoo","email":"satyajit.happy@gmail.com"},"license":"MIT","_id":"use-latest-callback@0.3.3","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":"62f3c2a949087605741624850e4be6429e8fe3f1","tarball":"http://registry-npm.ywwl.com/use-latest-callback/download/use-latest-callback-0.3.3.tgz","fileCount":7,"integrity":"sha512-G9A/EL7okx4wzBfATt8bdGg0v1K0Gp0IClTzljffM63gtPisgDKCaLCLUb4g2M4CoXDg5yyHjOU+g3SUPbXwrA==","signatures":[{"sig":"MEQCIGrkoVF4O2qlNVtsT1cIfgXI+6LfPoz0UXRWvOrXbrPHAiAlx6GkK9zbaZxZ8HVYC0Cvp06hkzmHVFCcnItAu2ZdDw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/use-latest-callback@0.3.3","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6388,"size":2735,"noattachment":false,"key":"/use-latest-callback/-/use-latest-callback-0.3.3.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":"5ed6a3156e46c424f1b87c02e17c109082682be2","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":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:de48a4ed-add2-4f3d-98c1-1ca5c504f10b"}},"release-it":{"git":{"tagName":"v${version}","commitMessage":"chore: release ${version}"},"npm":{"publish":true,"skipChecks":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":"11.6.4","description":"React hook which returns the latest callback without changing the reference","directories":{},"_nodeVersion":"24.11.1","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.3.3_1764356058921_0.6862274751767936","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":1764356059113,"_cnpm_publish_time":1764356059113,"dist-tags":{"latest":"0.3.5"}}