I have the following code:
export const StateContext = createContext({});
const StoreProvider: any = StateContext.Provider;
export const StateProvider = ({ reducer, initialState, children }: any) => (
<StoreProvider value={useReducer(reducer: any, initialState: any)}>
{children}
</StoreProvider>
);
but TypeScript is throwing an error 'StoreProvider' refers to a value, but is being used as a type here.
- why? I assume its seeing it as a generic, but how to make it see as is needed?
useReducer((reducer as any), (initialState as any))
– Viktor Zagoruyko