2022/03/18 (新增連結)
在react裡,元件與元件之間可以使用props傳遞資訊。但是,當元件很多的時候,最好就使用Context、Redux或者React提供的Recoil來處理。
Do You Know the 5 Types of States in React?
Logical State
Server State
Form State
Navigation State
Browser State
React Tracked: Manage State and Prevent Excessive Re-Rendering : In this tutorial, we’ll use React Tracked, a library for state usage tracking, to optimize our application’s performance by preventing unnecessary re-renders.React-tracked
Recoil: A New State Management Library Moving Beyond Redux and the Context API
Recoil.js — The New, Better State Management Library for React
Recoil.js — High-Performance State Management for React Simplified
Redux, Context, or Recoil: Which One Is Best for Your Modern Web App?
Using Recoil instead of Redux For State Management In React Applications
Recoil : State Management which is more like React
Atoms
useRecoilState
Selectors
useRecoilValue
React state management in 2022 — Return of the Redux
We will be discussing the following types of state:
Local State: Refers to state persisted within a React Component.
Global State: Refers to state persisted within a global store that all components have access to.
Server State: Refers to state persisted on a server. (and for the sake of this conversation — automatically managed in client cache, using a tool like React Query.)
You don’t need react-redux anymore
with react-redux we created too many files, such as: action types, action, reducers and write logic in reducers with a spread operation is boring.
with redux-toolkit we created only one file which generate for us all actions and action types, besides we can update logic using “mutating” syntax.