@@ -6,6 +6,9 @@ import { createSubscription } from '../utils/Subscription'
66import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
77import type { ReactReduxContextValue } from './Context'
88import { ReactReduxContext } from './Context'
9+ import { experimental } from 'react-concurrent-store'
10+ const { StoreProvider } = experimental
11+ import type { ReactStore } from '../utils/reactStoreEnhancer'
912
1013export interface ProviderProps <
1114 A extends Action < string > = UnknownAction ,
@@ -59,11 +62,20 @@ function Provider<A extends Action<string> = UnknownAction, S = unknown>(
5962) {
6063 const { children, context, serverState, store } = providerProps
6164
65+ // Validate store has reactStore
66+ if ( ! ( 'reactStore' in store ) ) {
67+ throw new Error (
68+ 'Redux store must be enhanced with addReactStore enhancer. ' +
69+ 'Apply the enhancer when creating your store.' ,
70+ )
71+ }
72+
6273 const contextValue = React . useMemo ( ( ) => {
6374 const subscription = createSubscription ( store )
6475
6576 const baseContextValue = {
6677 store,
78+ reactStore : store . reactStore as ReactStore ,
6779 subscription,
6880 getServerState : serverState ? ( ) => serverState : undefined ,
6981 }
@@ -99,7 +111,11 @@ function Provider<A extends Action<string> = UnknownAction, S = unknown>(
99111
100112 const Context = context || ReactReduxContext
101113
102- return < Context . Provider value = { contextValue } > { children } </ Context . Provider >
114+ return (
115+ < Context . Provider value = { contextValue as any } >
116+ < StoreProvider > { children } </ StoreProvider >
117+ </ Context . Provider >
118+ )
103119}
104120
105121export default Provider
0 commit comments