{"name":"use-latest-callback","version":"0.3.4","keywords":["react","use-event","use-callback"],"author":{"name":"Satyajit Sahoo","email":"satyajit.happy@gmail.com"},"license":"MIT","_id":"use-latest-callback@0.3.4","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":"5b70cc91d4cf4ae7b09b5599e37822cc0e604791","tarball":"http://registry-npm.ywwl.com/use-latest-callback/download/use-latest-callback-0.3.4.tgz","fileCount":7,"integrity":"sha512-IcR5xK/dJFzUUsAKBqr/mZw4dGPftRdVvx5+cNsLzDlf7V1GPNfnRTjiuTxSsfPtUJGW/KNrScl7xwQoOsvhkg==","signatures":[{"sig":"MEUCIDZmyXr/R/80P7Ma+PI0J4TpR0x6bOOdcGFW0lu2Rs64AiEA9ImSxD0yjIRW95mtlve05wwfEtwK3ELIZrHMrZEmXuw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/use-latest-callback@0.3.4","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":6388,"size":2733,"noattachment":false,"key":"/use-latest-callback/-/use-latest-callback-0.3.4.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":"401466ceb358785870bb06ce6603d33e956fca1e","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.14.1","description":"React hook which returns the latest callback without changing the reference","directories":{},"_nodeVersion":"24.14.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.4_1778678660525_0.2586943113383786","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":1778678660686,"_cnpm_publish_time":1778678660686,"dist-tags":{"latest":"0.3.5"}}