From 66182985a5737a5951393414071e752a12a63398 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Fri, 10 Feb 2023 19:35:21 +0800 Subject: [PATCH] :zap: perf: improve implement of useStoreApi --- src/context.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/context.ts b/src/context.ts index 3a3faed..d6a9a75 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,11 +1,5 @@ import type { ReactNode } from 'react'; -import { - createContext as reactCreateContext, - createElement, - useContext, - useMemo, - useRef, -} from 'react'; +import { createContext as reactCreateContext, createElement, useContext, useRef } from 'react'; import type { StoreApi } from 'zustand'; import { useStore } from 'zustand'; @@ -51,7 +45,7 @@ export const createContext = >() => { if (!store) { throw new Error('Seems like you have not used zustand provider as an ancestor.'); } - return useMemo>(() => ({ ...store }), [store]); + return store as WithoutCallSignature; }; return {