【发布时间】:2018-01-06 15:10:36
【问题描述】:
我正在运行这段代码:
.then((url) => {
if (url == null || undefined) {
return this.props.image;
} else {
const { image } = this.props;
//entryUpdate is an action creator in redux.
this.props.entryUpdate({ prop: 'image', value: url })
.then(() => {
this.setState({ loading: false });
});
但我收到以下错误:
如何在动作创建者之后调用的异步函数中格式化 setState()?
任何帮助将不胜感激!
【问题讨论】:
-
看起来
this.props.entryUpdate函数没有返回promise。 -
是的,我想通了。我把 .then() 函数放得太早了。感谢您的帮助!
标签: reactjs asynchronous react-native redux-thunk setstate