{"id":46734,"library":"use-memo-one","title":"use-memo-one","description":"useMemoOne and useCallbackOne are React hooks that provide a stable cache semantic guarantee, unlike the built-in useMemo and useCallback which React may clear at any time (e.g. for memory freeing). This is particularly useful for concurrent mode and cases where reference stability is critical. v1.1.3 is current and stable, with peer dependency on React ^16.8.0 || ^17.0.0 || ^18.0.0. It also exports aliases useMemo and useCallback for drop-in replacement, but those will clash with React's own hooks if imported together.","status":"active","version":"1.1.3","language":"javascript","source_language":"en","source_url":"https://github.com/alexreardon/use-memo-one","tags":["javascript","memoization","react","useMemo","useCallback","memoize-one"],"install":[{"cmd":"npm install use-memo-one","lang":"bash","label":"npm"},{"cmd":"yarn add use-memo-one","lang":"bash","label":"yarn"},{"cmd":"pnpm add use-memo-one","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required to use hooks","package":"react","optional":false}],"imports":[{"note":"Named export, not default. CommonJS: const { useMemoOne } = require('use-memo-one')","wrong":"import useMemoOne from 'use-memo-one'","symbol":"useMemoOne","correct":"import { useMemoOne } from 'use-memo-one'"},{"note":"Aliased export also available as useCallback. Using the named alias can clash with React's hooks.","wrong":"import { useCallback } from 'use-memo-one'","symbol":"useCallbackOne","correct":"import { useCallbackOne } from 'use-memo-one'"},{"note":"Aliased drop-in replacement for React's useMemo. Do not import both or you'll get a naming clash.","wrong":"import { useMemo } from 'react'","symbol":"useMemo","correct":"import { useMemo } from 'use-memo-one'"},{"note":"Aliased drop-in replacement for React's useCallback. Same caveat as useMemo.","wrong":"import { useCallback } from 'react'","symbol":"useCallback","correct":"import { useCallback } from 'use-memo-one'"}],"quickstart":{"code":"import { useMemoOne, useCallbackOne } from 'use-memo-one';\n\nfunction App({ name, age }) {\n  // useMemoOne guarantees stable reference until inputs change\n  const greeting = useMemoOne(() => `Hello, ${name}!`, [name]);\n  const getAge = useCallbackOne(() => age, [age]);\n\n  return <div>{greeting}</div>;\n}","lang":"typescript","description":"Demonstrates basic usage of useMemoOne and useCallbackOne with stable cache semantics."},"warnings":[{"fix":"Only import useMemo/useCallback from one source, or use the explicit useMemoOne/useCallbackOne names.","message":"Aliased exports useMemo and useCallback will clash if also imported from 'react'","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use only where reference stability is critical; otherwise prefer React's hooks for memory efficiency.","message":"useMemoOne consumes more memory than useMemo because it never clears cache until garbage collection","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"N/A","message":"No breaking changes released; package is stable at v1.1.3","severity":"breaking","affected_versions":"all"},{"fix":"Consider alternatives if newer React features are needed","message":"Package has not been updated since 2021; no known deprecation but may lag behind React changes","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'16.8.0':61 '17.0.0':62 '18.0.0':63 'alias':67 'also':65 'built':21 'built-in':20 'cach':15 'case':45 'clash':79 'clear':29 'concurr':42 'critic':50 'current':53 'depend':58 'drop':73 'drop-in':72 'e.g':33 'export':66 'free':36 'guarante':17 'hook':10,84 'import':86 'javascript':88 'may':28 'memo':3 'memoiz':89,94 'memoize-on':93 'memori':35 'mode':43 'one':4,95 'particular':39 'peer':57 'provid':12 'react':9,27,60,81,90 'refer':47 'replac':75 'semant':16 'stabil':48 'stabl':14,55 'time':32 'togeth':87 'unlik':18 'use':2,40 'use-memo-on':1 'usecallback':25,70,92 'usecallbackon':7 'usememo':23,68,91 'usememoon':5 'v1.1.3':51","created_at":"2026-06-07T13:01:22.436158+00:00","updated_at":"2026-06-07T13:01:22.436158+00:00","problems":[{"fix":"Use CommonJS require: const { useMemoOne } = require('use-memo-one'); or ensure bundler supports CJS interop.","cause":"Using a bundler that expects CJS but trying named import from a CJS package that doesn't have named exports properly configured.","error":"Attempted import error: 'useMemoOne' is not exported from 'use-memo-one'."},{"fix":"Move the hook call inside a function component or a custom hook.","cause":"Calling useMemoOne or useCallbackOne outside a React functional component or custom hook.","error":"Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component."},{"fix":"Ensure hooks are called unconditionally and in the same order on every render.","cause":"Conditionally calling useMemoOne/useCallbackOne, violating Rules of Hooks.","error":"Warning: React has detected a change in the order of Hooks called by App."},{"fix":"Upgrade React to ^16.8.0 || ^17.0.0 || ^18.0.0 as per peerDependencies.","cause":"Using an older version of React that doesn't support or misinterprets the custom hooks.","error":"Cannot read property 'memoizedValue' of null"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/alexreardon/use-memo-one#readme","github":"https://github.com/alexreardon/use-memo-one","docs":null,"changelog":null,"pypi":null,"npm":"use-memo-one","openapi_spec":null,"status_page":null,"smithery":null,"categories":["productivity"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}