随笔分类 - Redux
摘要:Config store app/store.ts import { configureStore } from "@reduxjs/toolkit"; export const store = configureStore({ reducer: {} }); main.tsx import Rea
阅读全文
摘要:This lesson demonstrates that you can get a small performance gain by removing AJAX calls that feed into redux from the react/hooks lifecycle. In this
阅读全文
摘要:Highlights: Solve the complexities of write Redux (actions, reducers, selector...middleware...) Solve the immutable pattern with nested spread operato
阅读全文
摘要:import { SET_STATUS, FETCH_FULFILLED, FETCH_FAILED, RESET, } from '../actions/beerActions' import lensProp from 'ramda/es/lensProp' import set from 'r
阅读全文
摘要:Higher Order Reducers are simple reducer factories, that take a reducer as an argument and return a new reducer. In that new reducer, you can customiz
阅读全文
摘要:Redux is one of the most popular state-management libraries and although not specific to React, it is widely used with it. This is why the author of P
阅读全文
摘要:Root Smart component can be overloaded, divide 'smart' component wisely & using Provider. Problem: Something the root component can be overloaded, mea
阅读全文
摘要:In redux, the action type is just a normal string type, it is easy to get naming conflicts in large application. Can use namespace-constants lib to so
阅读全文
摘要:Webpack will hot reload the component, but the reducer we need hard refresh. To sovle the problem, go to the store.js: We just need to config the 'red
阅读全文
摘要:If you have props and actions, you want one component to access those props and actions, one solution is pass those from parent to this component. But
阅读全文
摘要:We will learn how to fire up an async request when the route changes. A mock server data: We want to replace localStorge with mock server data, so rem
阅读全文
摘要:We will learn how centralized updates in Redux let us log every state change to the console along with the action that caused it.
阅读全文
摘要:We will learn how to normalize the state shape to ensure data consistency that is important in real-world applications. We currently represent the tod
阅读全文
摘要:We will learn how to encapsulate the knowledge about the state shape in the reducer files, so that the components don’t have to rely on it. In current
阅读全文
摘要:We will learn how to avoid the boilerplate code in mapDispatchToProps() for the common case where action creator arguments match the callback prop arg
阅读全文
摘要:We will learn how to use withRouter() to inject params provided by React Router into connected components deep in the tree without passing them down a
阅读全文
摘要:We will learn how adding React Router shifts the balance of responsibilities, and how the components can use both at the same time. Now when we click
阅读全文
摘要:We will learn how to change the address bar using a component from React Router. In Root.js: We need to add a param to change the Route: (:filter) mea
阅读全文
摘要:We will learn how to add React Router to a Redux project and make it render our root component. Install: Router should be wrapped inside Provider, the
阅读全文
摘要:We will learn how to better separate the code in the entry point to prepare it for adding the router. Currently, in the index.js, we configure the sto
阅读全文