Skip to content

Commit b50f392

Browse files
authored
Provider: pass state (S) generic through to ProviderProps
This is necessary to catch mistakes such as this, where the type of `serverState` does not match the type of the state in the provided `store`. ```tsx import { Provider } from 'react-redux'; import { Store } from 'redux'; declare const store: Store<{ foo: string }>; <Provider store={store} serverState={"oops"}>foo</Provider> ```
1 parent 70a167e commit b50f392

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ export interface ProviderProps<A extends Action = AnyAction, S = any> {
2424
children: ReactNode
2525
}
2626

27-
function Provider<A extends Action = AnyAction>({
27+
function Provider<A extends Action = AnyAction, S = any>({
2828
store,
2929
context,
3030
children,
3131
serverState,
32-
}: ProviderProps<A>) {
32+
}: ProviderProps<A, S>) {
3333
const contextValue = useMemo(() => {
3434
const subscription = createSubscription(store)
3535
return {

0 commit comments

Comments
 (0)