Redux

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.

Readux

Features of React.js: There are unique features are available on React because that it is widely popular.

  • Use JSX: It is faster than normal JavaScript as it performs optimizations while translating to regular JavaScript. It makes it easier for us to create templates.
  • Virtual DOM: Virtual DOM exists which is like a lightweight copy of the actual DOM. So for every object that exists in the original DOM, there is an object for that in React Virtual DOM. It is exactly the same, but it does not have the power to directly change the layout of the document. Manipulating DOM is slow, but manipulating Virtual DOM is fast as nothing gets drawn on the screen.
  • One-way Data Binding: This feature gives you better control over your application.
  • Component: A Component is one of the core building blocks of React. In other words, we can say that every application you will develop in React will be made up of pieces called components. Components make the task of building UIs much easier. You can see a UI broken down into multiple individual pieces called components and work on them independently and merge them all in a parent component which will be your final UI.
  • Performance: React.js use JSX, which is faster compared to normal JavaScript and HTML. Virtual DOM is a less time taking procedure to update webpages content.

  1. install Redux library
                    
                        npm install redux react-redux
                    
                
  2. File structure in src folder (use cmd)
        
          mkdir actions reducers
    
    
  3. ADD blank many js files(create store file in src)
        
          type NUL > store.js
    
    
  4. in 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;
    
    
  5. In actions/index.js
        
            export const incNumber = (num) => {
                return {
                    type: 'INCREMENT',
                    payload: num
                }
            }
            
            export const decNumber = () => {
                return {
                    type: 'DECREMENT'
                }
            };