UseDeepMemo Imported From @hooks/deepMemo
useDeepMemo` imported from `@hooks/deepMemo`, memoizes dependencies with deep equality, returning same value on unchanged deps. Used in Refine's query client creation.
In this article, we will review a function named useDeepMemo found in Refine source code.
const queryClient = useDeepMemo(() => {
if (reactQueryWithDefaults.clientConfig instanceof QueryClient) {
return reactQueryWithDefaults.clientConfig;
}
return new QueryClient({
...reactQueryWithDefaults.clientConfig,
defaultOptions: {
...reactQueryWithDefaults.clientConfig.defaultOptions,
queries: {
refetchOnWindowFocus: false,
keepPreviousData: true,
...reactQueryWithDefaults.clientConfig.defaultOptions?.queries,
},...