1 import { type ReactNode } from 'react';
2 import { Provider, type TypedUseSelectorHook } from 'react-redux';
4 import type { Action } from '@reduxjs/toolkit';
5 import type { Store } from 'redux';
7 import { ProtonStoreContext, baseUseDispatch, baseUseSelector, baseUseStore } from '@proton/react-redux-store';
8 import { ModelThunkDispatcher } from '@proton/redux-utilities';
10 import type { SharedStore } from './sharedStore';
12 type UseProtonDispatch = SharedStore['dispatch'];
13 type SharedState = ReturnType<SharedStore['getState']>;
15 export interface ProtonStoreProviderProps<S = any, A extends Action = Action> {
20 export const ProtonStoreProvider = ({ children, store }: ProtonStoreProviderProps) => {
22 <Provider context={ProtonStoreContext} store={store}>
23 <ModelThunkDispatcher>{children}</ModelThunkDispatcher>
28 export const useStore: () => SharedStore = baseUseStore;
29 export const useDispatch: () => UseProtonDispatch = baseUseDispatch;
30 export const useSelector: TypedUseSelectorHook<SharedState> = baseUseSelector;