我正面临 Redux 和 React 的问题
我使用 redux 操作从 API 获取数据。当组件挂载时,会触发此操作并填充 Redux 状态。我希望使用article来自 redux 状态的参数 ( )触发第二个操作。
我的问题是,当我触发第二个动作时,redux 状态仍然为空,因此article为空,这会导致错误。
componentDidMount() {
const { targetArticle, userVisit, match, article } = this.props
targetArticle(match.params.slug);
userVisit(match.params.slug, article.title);
}
Run Code Online (Sandbox Code Playgroud)
我已经检查了类似主题的其他主题这一个,但没有人对我的作品。我怎样才能做到这一点?
谢谢