React Native 中的状态管理(如同 React 中一样)从本地组件状态 (useState) 到通过 Context 或库(如 Redux、Zustand 等)进行的共享/全局状态。理解这些选项以及何时使用每一个很重要,因为应用会不断增长。
本地状态和状态提升
useState → local component state (simple, for one component)
LIFTING STATE UP → move shared state to a common parent, pass down via props
→ works for moderate sharing, but "PROP DRILLING" (passing through many layers) is painful
Context API — 内置共享状态
= ();
theme = ();
