2021 第50週 學習記錄:MuiTabs、React.useEffect

總結

本週最大發現: React.useEffect 也有訂閱的功能;useEffect 也是支援傳入 dependency 變數的 其餘筆記包含如何使用 MuiTabs 搭配 MuiTab

筆記

使用變數或 enum 管理起始值、預設值

// 比如以下
const CONDITION = {
  page: 0,
  query: '',
};

enum STEP {
  ORDER = 'order',
  SUMMARY = 'summary',
}

換頁時維持勾選狀態

調整 MuiCheckBox 框線粗細

MuiTabs 動態顯示對應內容

demo

React.useEffect with condition

Think of setState() as a request rather than an immediate command to update the component. For better perceived performance, React may delay it, and then update several components in a single pass. React does not guarantee that the state changes are applied immediately. setState() does not always immediately update the component. It may batch or defer the update until later.

參考文件