import { createStore, applyMiddleware } from '@reduxjs/toolkit';
import rootReducer from './reducers';
import { composeWithDevTools } from 'redux-devtools-extension';
import thunk from 'redux-thunk';
import reduxImmutableStateInvariant from 'redux-immutable-state-invariant';
export const store = (initialState: any) => {
const enhancer =
process.env.NODE_ENV === 'production'
? applyMiddleware(thunk)
: composeWithDevTools(applyMiddleware(...[reduxImmutableStateInvariant()], thunk));
return createStore(rootReducer, initialState, enhancer);
};
export default store;
const getStateStore = store({}).getState;
export type RootState = ReturnType<typeof getStateStore>;
export { getStateStore };