0
考慮以下Redux的代碼,比較緩存狀態的Redux模式?
let cacheState = {};
const mapStateToProps = (state, ownProps) => {
const zug = cacheState.bar === state.bar ? "qux" : "doo";
return {
foo: state.bar,
zug
};
cacheState = state;
};
此代碼示例骨刺以下觀察:
1)這似乎是在一個終極版部件
2緩存狀態的唯一方式)本將從這個模板創建多個Redux組件時中斷
3)這是一個反模式
組件注意以前狀態的正確方法是什麼?