【发布时间】:2018-12-15 04:46:32
【问题描述】:
如果在块中调度同步操作,它下面的行会注意到变化吗?
// In a compoent connected to the reducer
class someComponent extends Component {
const interuptOrNot = () => {
this.props.dispatchChangeSomeStateAction({ payload: 2 })
}
render() {
this.interuptOrNot()
console.log(this.props.someState)
return(<SomeComponent>)
}
}
如果 reducer 的原始 props 值等于 1,那么记录器的输出信息是什么。 1 还是 2?或者第一次渲染调用没有输出,但它会输出 2 用于最新状态的重新渲染。
我知道在渲染函数中发送动作是个坏主意,但是如果我调度一些动作来改变组件使用的减速器的状态会发生什么?
如果dispatchChangeSomeStateAction 向reducer 分派一个同步redux action,我在render 函数中调用这个函数怎么办?当前渲染是否会因为状态过期而中止?
【问题讨论】:
标签: reactjs react-redux