My Brain
My Brain

React Notes

Environment Variables

Redux

  1. Create reducer.js file

    const initialState = { persons: [] }
    import * as actionTypes from './actions'
    
    const reducer = (state = initialState, action) => {
        switch (action.type) {
    
        }
    }
    
    export default reducer
  2. Create actions.js file in order to use the actionTypes shown above:

    export const ADD_PERSON = 'ADD_PERSON'
    export const REMOVE_PERSON = 'REMOVE_PERSON'
  3. In index.js wrap <App /> with <Provider>:

    import { Provider } from 'react-redux'
    
        <Provider>
            <App />
        </Provider>,
  4. Create the store in that same index.js:

    import reducer from './store/reducer'
    import { createStore } from 'redux'
    
    const store = createStore(reducer)
    
    // And pass it to the provider:
    
    ReactDOM.render(
        <Provider store={store}>
            <App />
        </Provider>,
        document.getElementById('root')
    )
  5. Create the switch in the reducer

Don't show [HMR] Waiting for update signal from WDS... in console

In node_modules/webpack/hot/log.js, comment:

module.exports = function(level, msg) {
  // if (shouldLog(level)) {
  // if (level === "info") {
  // console.log(msg);
  // } else if (level === "warning") {
  // console.warn(msg);
  // } else if (level === "error") {
  // console.error(msg);
  // }
  // }
};

Backlinks