1.0.1 • Published 5 years ago
react-redux-thunk-store v1.0.1
React Redux Thunk Store
To simplyfi the redux store creattion and management. I developed this library to help to create and manage the store easier and simpler.
It fully compatible with redux tool for Chrome to monitor the state in DEVELOPMENT mode.
Installation
mpn install --save-dev redux-devtools-extension redux-immutable-state-invariant
npm install --save-dev react-redux-thunk-store
Sample:
import React from "react";
import Provider from "react-redux-thunk-store";
import ReactDOM from "ReactDOM";
const reducer = (store = [], action) => {
//This is sample reducer
if (action.type === "LOADDED") return [{ id: 1 }];
return store;
};
const rootRecuders ={
values:reducer,
others:otherReducer,
...
}
ReactDOM.render(
<Provider reducers={rootRecuders}>
<div>Hello Store</div>
</Provider>,
document.getElementById("root")
);
NextJs Support
Beow is the sample code if you using NextJs.
import withRedux from 'next-redux-wrapper';
import createStore from 'react-redux-thunk-store/storeCreator';
//Using the react-redux Provider
import { Provider } from 'react-redux';
//Your reducers but not combineReducers
import reducers from './reducers';
const makeStore = () => createStore(reducers, initialState);
export default withRedux(makeStore)(
class extends App {
render() {
<Provider store={store}>
<Component {...pageProps} />
</Provider>;
}
}
);
Properties
1. reducers Required
This is required property which proviced an object contains all your reducers.
2. initialState option
Provide the initialState to the Redux store.
3. middleWares option
Provide the custom middle-wares to the Redux store.