{"_id":"use-latest-callback@0.3.5","bugs":{"url":"https://github.com/satya164/use-latest-callback/issues"},"dist":{"shasum":"9f2cb20662d848bab34178315dfbb3ba9def1b10","tarball":"http://registry-npm.ywwl.com/use-latest-callback/download/use-latest-callback-0.3.5.tgz","fileCount":7,"integrity":"sha512-YDTKaeth5egzJLLKxGDvfoajkiZbNbLEaZnvnHXjSt5FDVy1WgPLwXXKdtBDIXDeakBrE4wBJuf2FTFBXzVw4Q==","signatures":[{"sig":"MEYCIQD+YzIeZe1B5CVizdvPQqiaBGfeO1Iyc8/0yVBpYf+93AIhAJABtePRsFX6YAXeg5PGp9ZY+4nbAPygZfN7I0rrdmc1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCFOLa/+Sc++CfgI5cyGLpUgl6UCfMt1AV2I6YtUcA87AIgZonwb2/GaYdAvUuVgYQXtCBAG7sTVzu4bJDVSwBg0dQ="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/use-latest-callback@0.3.5","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":5765,"size":2594,"noattachment":false,"key":"/use-latest-callback/-/use-latest-callback-0.3.5.tgz"},"main":"./lib/src/index.js","name":"use-latest-callback","type":"commonjs","types":"./lib/src/index.d.ts","author":{"name":"Satyajit Sahoo","email":"satyajit.happy@gmail.com"},"source":"./src/index.ts","exports":{".":{"types":"./lib/src/index.d.ts","import":"./esm.mjs","default":"./lib/src/index.js"}},"gitHead":"b209e052cecc03257982d6fb717fa7d07c6c9bb2","license":"MIT","scripts":{"lint":"eslint \"**/*.{js,ts,tsx}\"","test":"node --test","build":"tsc --declaration","prepare":"yarn build","release":"release-it","prebuild":"del lib","typecheck":"tsc --noEmit"},"version":"0.3.5","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:de48a4ed-add2-4f3d-98c1-1ca5c504f10b"}},"homepage":"https://github.com/satya164/use-latest-callback#readme","keywords":["react","use-event","use-callback"],"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":"12.0.1","description":"React hook which returns the latest callback without changing the reference","directories":{},"maintainers":[{"name":"satya164","email":"satyajit.happy@gmail.com"}],"_nodeVersion":"24.18.0","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":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/use-latest-callback_0.3.5_1785070960911_0.5957200063260082"},"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":1785070960993,"_cnpm_publish_time":1785070960993,"dist-tags":{"latest":"0.3.5"}}