Last active
February 27, 2025 22:24
-
-
Save KacperKozak/733562fe02969919d18d17ead93b84ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useMemo } from 'react'; | |
/** | |
* A hook that returns a memoized version of the given object or array. | |
* **Important!** Use only if the object structure or array length is not changing! | |
* | |
* @example | |
* ```ts | |
* const api = useStructMemo({ query, setQuery, count }); | |
* ``` | |
*/ | |
export const useStructMemo = <T extends object>(obj: T) => { | |
return useMemo(() => obj, Object.values(obj)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment