Skip to content

Commit

Permalink
shave 5 bytes prop spreading (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
charkour authored Dec 21, 2023
1 parent 8a1cf7f commit 8035bd9
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ export const createContext = <
>() => {
const StoreContext = reactCreateContext<Store | undefined>(undefined);

const Provider: React.FC<{
createStore: () => Store;
children: React.ReactNode;
}> = ({ createStore, children }) => {
type Provider = React.FC<
{
createStore: () => Store;
children: React.ReactNode;
} & Record<string, unknown>
>;

const Provider: Provider = ({ createStore, ...rest }) => {
const storeRef = useRef<Store>();
return createElement(StoreContext.Provider, {
value: (storeRef.current ||= createStore()),
children,
...rest,
});
};

Expand Down

0 comments on commit 8035bd9

Please sign in to comment.