状态管理是复杂前端应用的核心问题。
Redux
import { createStore } from 'redux';
const reducer = (state = 0, action) => {
switch(action.type) {
case 'INCREMENT': return state + 1;
default: return state;
}
};
const store = createStore(reducer);选择建议
- Redux - 大型项目
- Mobx - 中小型项目
- Zustand - 轻量级方案
评论 (0)
暂无评论,来发表第一条评论吧!
发表评论