React Notes
Environment Variables
Redux
Create reducer.js file
const initialState = { persons: [] } import * as actionTypes from './actions' const reducer = (state = initialState, action) => { switch (action.type) { } } export default reducer
Create actions.js file in order to use the actionTypes shown above:
export const ADD_PERSON = 'ADD_PERSON' export const REMOVE_PERSON = 'REMOVE_PERSON'
In
index.js
wrap<App />
with<Provider>
:import { Provider } from 'react-redux' <Provider> <App /> </Provider>,
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') )
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
Knowledge Base
- [[react]]