Skip to content

Commit

Permalink
⚡ perf: improve implement of useStoreApi
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Feb 10, 2023
1 parent 2f4b7f6 commit 6618298
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -51,7 +45,7 @@ export const createContext = <S extends StoreApi<unknown>>() => {
if (!store) {
throw new Error('Seems like you have not used zustand provider as an ancestor.');
}
return useMemo<WithoutCallSignature<S>>(() => ({ ...store }), [store]);
return store as WithoutCallSignature<S>;
};

return {
Expand Down

0 comments on commit 6618298

Please sign in to comment.