2020-11-01から1ヶ月間の記事一覧

Redux Reselect

*to memoize state so that every time mapStateToProps is called it does not re-render components that do not need to be re-rendered Install reselect npm i reselect Create selectors hoge.selectors.js import { createSelector } from 'reselect'…

Redux Practice Example 3

Provider to index.js index.js import { Provider } from 'react-redux'; import { store } from './redux/store.js'; <Provider store={store}> <App /> </Provider>, Connect to components hoge.js *use the state or dispatch as props of the component const mapStateToProps = (state) => ({ ho…

Redux Practice Example 2

Creating ActionTypes hoge.types.js export const HogeActionTypes = { HOGE: 'HOGE', }; Creating Actions (for dispatching) hoge.actions.js import HogeActionTypes from './hoge.types.js'; export const hoge = () => ({ type: CartActionTypes.HOGE,…

Redux Practice Example

Installing Redux npm i redux redux-logger react-redux Creating store store.js import { createStore, applyMiddleware } from 'redux'; import logger from 'redux-logger'; import rootReducer from './root-reducer.js'; const middleWares = [logger…

Redux Notes

*redux notes Redux Redux Introduction ・state management ・get rid of all states in components ・put them in a store and pass the state to the component that needs it Why Redux ・Good for managing large state ・Useful for sharing data betw…