chapter-03代码有错误:this.context.store.unsubscribe(this.onChange)
yuanhjty opened this issue · comments
shaozhiyuan commented
在 redux_basic, redux_smart_dumb, redux_with_context 实现 componentWillUnmount 时都用了
componentWillUnmount() {
this.context.store.unsubscribe(this.onChange);
}
Redux store 没有 unsubscribe 这个 api,但是由于 这个几个例子中 componentWillUnmount 永远不会被调用,所以构建和运行时并不会报错。
N. Anderson commented
https://redux.js.org/basics/store
補充一下,
// Note that subscribe() returns a function for unregistering the listener
const unsubscribe = store.subscribe(() =>
console.log(store.getState())
)
執行 subscribe 後回傳的函數來解除.
SoftwareEngineerPalace commented
2年了 作者也不来回复