Need help with use-memo-value?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

159 Stars 7 Forks MIT License 5 Commits 6 Opened issues


Reuse the previous version of a value unless it has changed

Services available


Need anything else?

Contributors list


Reuse the previous version of a value unless it has changed


npm install --save-dev use-memo-value


If you don't know all the members of an object, you may want to use a "shallow compare" to memoize the value so you can rely on React's referential equality (such as in

useEffect(..., deps)
import useMemoValue from "use-memo-value"

function MyComponent(props) { let rawParams = getCurrentUrlQueryParams() // we don't know the shape of this object let memoizedParams = useMemoValue(rawParams)

useEffect(() => { search(memoizedParams) }, [memoizedParams])

// ... }

Note: If you know the shape of your object, you are likely better off not using this library.

If you need to customize how the values are compared, you can pass a comparator as a second argument:

let memoizedValue = useMemoValue(rawValue, (nextValue, previousValue) => {
  return, b) // or whatever

The comparator will not be called until there's a new value.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.