Registry / productivity / use-memo-one

use-memo-one

JSON →
library1.1.3jsnpmunverified

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.

npm install use-memo-one
INSTALL
IMPORT
SIG · USE-MEMO-ONE
U
use-memo-one
productivityjavascriptv1.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useMemoOne
✓ import { useMemoOne } from 'use-memo-one'
✗ import useMemoOne from 'use-memo-one'
Named export, not default. CommonJS: const { useMemoOne } = require('use-memo-one')
useCallbackOne
✓ import { useCallbackOne } from 'use-memo-one'
✗ import { useCallback } from 'use-memo-one'
Aliased export also available as useCallback. Using the named alias can clash with React's hooks.
useMemo
✓ import { useMemo } from 'use-memo-one'
✗ import { useMemo } from 'react'
Aliased drop-in replacement for React's useMemo. Do not import both or you'll get a naming clash.
useCallback
✓ import { useCallback } from 'use-memo-one'
✗ import { useCallback } from 'react'
Aliased drop-in replacement for React's useCallback. Same caveat as useMemo.

Demonstrates basic usage of useMemoOne and useCallbackOne with stable cache semantics.

import { useMemoOne, useCallbackOne } from 'use-memo-one'; function App({ name, age }) { // useMemoOne guarantees stable reference until inputs change const greeting = useMemoOne(() => `Hello, ${name}!`, [name]); const getAge = useCallbackOne(() => age, [age]); return <div>{greeting}</div>; }
Debug
Known issues
gotchaAliased exports useMemo and useCallback will clash if also imported from 'react'
fix
Only import useMemo/useCallback from one source, or use the explicit useMemoOne/useCallbackOne names.
affects: >=1.0.0
gotchauseMemoOne consumes more memory than useMemo because it never clears cache until garbage collection
fix
Use only where reference stability is critical; otherwise prefer React's hooks for memory efficiency.
affects: >=1.0.0
breakingNo breaking changes released; package is stable at v1.1.3
fix
N/A
affects: all
deprecatedPackage has not been updated since 2021; no known deprecation but may lag behind React changes
fix
Consider alternatives if newer React features are needed
affects: >=1.0.0
Errors
Common errors & fixes
Attempted import error: 'useMemoOne' is not exported from 'use-memo-one'.
Using a bundler that expects CJS but trying named import from a CJS package that doesn't have named exports properly configured.
fix
Use CommonJS require: const { useMemoOne } = require('use-memo-one'); or ensure bundler supports CJS interop.
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component.
Calling useMemoOne or useCallbackOne outside a React functional component or custom hook.
fix
Move the hook call inside a function component or a custom hook.
Warning: React has detected a change in the order of Hooks called by App.
Conditionally calling useMemoOne/useCallbackOne, violating Rules of Hooks.
fix
Ensure hooks are called unconditionally and in the same order on every render.
Cannot read property 'memoizedValue' of null
Using an older version of React that doesn't support or misinterprets the custom hooks.
fix
Upgrade React to ^16.8.0 || ^17.0.0 || ^18.0.0 as per peerDependencies.
Upgrade
Version history
1.1.3latest on npm
Audit
Dependencies
reactrequiredPeer dependency: required to use hooks
Agent activity
29 hits · last 30 days
node
26
OpenAI (training)
1
Resources
use-memo-one — npm install use-memo-one · libregistry