【发布时间】:2019-09-03 19:41:35
【问题描述】:
你能告诉我为什么不在 react 中获取更新的 props 值吗?
这是我的代码 https://stackblitz.com/edit/react-redux-basic-counter-1e8gdh?file=shared/components/NavBar.js
在我的示例中,我有一个按钮 - 。单击它会减小值。我发送的操作值为decremented,但我没有收到updated value
handle=()=>{
this.props.decrement();
this.getCount();
}
getCount=()=>{
const {counter}= this.props;
console.log(counter);
}
查看我的 console.log
预期输出为 -1
当前输出为0
为什么?当我点击 - 按钮时它显示输出
【问题讨论】:
标签: javascript reactjs redux react-redux