import { configureStore } from '@reduxjs/toolkit' ; import type { Context } from 'react' ; import React from 'react' ; import type { ReactReduxContextValue } from 'react-redux' ; import { Provider } from 'react-redux' ; import { setupListeners } from '@reduxjs/toolkit/query' ; import type { Api } from '@reduxjs/toolkit/dist/query/apiTypes' ; example remarks export function ApiProvider < A extends Api < any , { } , any , any > > ( props ) { const [ store ] = React . useState ( ( ) => configureStore ( { reducer : { [ props . api . reducerPath ] : props . api . reducer , } , middleware : ( gDM ) => gDM ( ) . concat ( props . api . middleware ) , } ) ) ; setupListeners ( store . dispatch , props . setupListeners ) ; return ( < Provider store = { store } context = { props . context } > { props . children } < /Provider>); }