import { ComponentProps , ReactNode } from 'react' ; import { configureStore , PreloadedState } from '@reduxjs/toolkit' ; import { Provider } from 'react-redux' ; import { MemoryRouter as Router } from 'react-router-dom' ; import { ThemeProvider } from 'styled-components' ; import { mockAppState } from 'test-utils' ; import { FeatureFlagProvider } from '@services' ; import { AppState , rootReducer } from '@store' ; import { theme } from '@theme' ; export const ProvidersWrapper = ( { children , initialState = mockAppState ( ) , initialRoute } ) => { const store = configureStore ( { reducer : rootReducer , preloadedState : ( initialState as unknown ) as PreloadedState < AppState > } ) ; return ( < Router initialEntries = { initialRoute ? [ initialRoute ] : undefined } > < Provider store = { store } > < FeatureFlagProvider > < ThemeProvider theme = { theme } > { children } < /ThemeProvider> < /FeatureFlagProvider> < /Provider> < /Router>); } ; param state export const withOptions = ( state ? , route ? ) => ( props ) => ( < ProvidersWrapper initialState = { state } initialRoute = { route } { ... props } > { props . children } < /ProvidersWrapper>);