@datns/store-configuration
v0.3.1
Published
Redux store configuration
Downloads
2
Readme
@datns/store-configuration
Library for default redux store configuration
Setup
yarn
Build
yarn build
ENV
To enable redux extension NODE_ENV='development'
To change the basepath / basename of your application BASENAME='/whatever
Usage
Step 1
In your reducers.ts
import { combineReducers } from 'redux'
import { connectRouter } from 'connected-react-router'
export default (history) => combineReducers({
router: connectRouter(history),
... // rest of your reducers
})
Step 2
In your index.ts
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'connected-react-router'
import { configureStore } from '@datns/store-configuration';
import { rootReducer } from './reducers';
const storeConfig = {
id: 'app-id',
rootReducer: rootReducer,
whitelist: ['version'],
};
const { store } = configureStore(storeConfig);
...
ReactDOM.render(
<Provider store={store}>
<ConnectedRouter history={history}> { /* place ConnectedRouter under Provider */ }
<App />
</ConnectedRouter>
</Provider>,
document.getElementById('react-root')
)
Libs used in configuration
history (Manage session history with JavaScript)
redux-persist (persist and rehydrate a redux store)
connected-react-router (A Redux binding for React Router v4)
redux-thunk (Thunk middleware for Redux)
License
@datns/store-configuration is MIT licensed.