官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 隆德县| 望都县| 梅河口市| 金门县| 阿勒泰市| 三原县| 灵武市| 赤水市| 乌拉特中旗| 米泉市| 确山县| 咸阳市| 无极县| 安顺市| 密云县| 民权县| 大方县| 抚顺县| 宣城市| 广安市| 吴旗县| 宣汉县| 澄江县| 平舆县| 嘉祥县| 福鼎市| 娱乐| 静宁县| 上犹县| 景谷| 绥江县| 泰州市| 静海县| 黄大仙区| 巧家县| 嘉鱼县| 马尔康县| 大同县| 常熟市| 黔江区| 虎林市|