Skip to content

Commit d2b2206

Browse files
committed
fix: type
1 parent b2ebfc0 commit d2b2206

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/foxact/src/context-state/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import { createContext, useContext, useState } from 'react';
55
import { noop } from '../noop';
66
import type { Foxact } from '../types';
77

8-
type ProviderProps<T> = Foxact.PropsWithChildren<{
9-
initialState?: T
10-
}>;
8+
interface ProviderProps<T> {
9+
initialState?: T | (() => T)
10+
}
1111

1212
/** @see https://foxact.skk.moe/context-state */
1313
export function createContextState<T>(initialState: T): [
@@ -17,7 +17,7 @@ export function createContextState<T>(initialState: T): [
1717
StateContext: React.Context<T>
1818
];
1919
export function createContextState<T>(): [
20-
Provider: React.ComponentType<Required<ProviderProps<T>>>,
20+
Provider: React.ComponentType<Foxact.PropsWithChildren<Required<ProviderProps<T>>>>,
2121
useValue: () => T,
2222
useSetValue: () => React.Dispatch<React.SetStateAction<T>>,
2323
StateContext: React.Context<T>
@@ -29,7 +29,7 @@ export function createContextState(initialState?: unknown): unknown {
2929
const useValue = () => useContext(StateContext);
3030
const useSetValue = () => useContext(DispatchContext);
3131

32-
const Provider = ({ children, initialState: initialStateFromProps }: ProviderProps<unknown>) => {
32+
const Provider = ({ children, initialState: initialStateFromProps }: Foxact.PropsWithChildren<ProviderProps<unknown>>) => {
3333
const [value, setValue] = useState((initialStateFromProps ?? initialState));
3434

3535
return (

0 commit comments

Comments
 (0)