- React Cookbook
- Carlos Santana Roldan
- 128字
- 2021-07-16 17:49:37
Using local state in a component
The local state is a fundamental feature of React for creating dynamic components. Local state is only available on class components, and each component manages its state. You can define the initial value of the state on the component's constructor, and when you update the value of the state, the component will be re-render itself.
Local state is helpful with toggles, for handling forms, and is used to manage information within the same component. It is not recommended to use local state if we need to share data between different components. In that scenario, we need to implement Redux state, which we will cover in Chapter 5, Mastering Redux.
推薦閱讀
- 智慧城市:大數據、互聯網時代的城市治理(第4版)
- 網絡云百問百答
- 網絡協議工程
- 5G承載網網絡規劃與組網設計
- Oracle SOA Suite 11g Performance Tuning Cookbook
- 走進物聯網
- 物聯網+BIM:構建數字孿生的未來
- Wireshark網絡分析就這么簡單
- 中小型局域網組建、管理與維護實戰
- Bonita Open Solution 5.x Essentials
- 互聯網+思維與創新:通往未來的+號
- 深入理解OpenStack Neutron
- Microsoft Power Platform Enterprise Architecture
- 結網@改變世界的互聯網產品經理(修訂版)
- LiveCode Mobile Development Beginner's Guide