Redux is a predictable state container for JavaScript apps. It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger. You can use Redux together with React, or with any other view library. It is tiny (2kB, including dependencies), but has a large ecosystem of addons available.
Features of React.js: There are unique features are available on React because that it is widely popular.
npm install redux react-redux
mkdir actions reducers
type NUL > store.js
import { createStore } from "redux";
import reducers from "./reducers/index";
const store = createStore(reducers, window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__());
export default store;
export const incNumber = (num) => {
return {
type: 'INCREMENT',
payload: num
}
}
export const decNumber = () => {
return {
type: 'DECREMENT'
}
};