Skip to content

Commit

Permalink
Provider: pass state (S) generic through to ProviderProps
Browse files Browse the repository at this point in the history
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>
```
  • Loading branch information
OliverJAsh authored Oct 6, 2022
1 parent 70a167e commit b50f392
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export interface ProviderProps<A extends Action = AnyAction, S = any> {
children: ReactNode
}

function Provider<A extends Action = AnyAction>({
function Provider<A extends Action = AnyAction, S = any>({
store,
context,
children,
serverState,
}: ProviderProps<A>) {
}: ProviderProps<A, S>) {
const contextValue = useMemo(() => {
const subscription = createSubscription(store)
return {
Expand Down

0 comments on commit b50f392

Please sign in to comment.