【发布时间】:2018-02-16 01:32:21
【问题描述】:
我想在查询完成后立即分派一个 redux 操作。 – 哪里是合适的地方?
这里我保留了对refetch 函数的引用,以便以后可以轻松地使用最新数据更新视图。
export default graphql(
allFilesQuery,
{
props: ({ ownProps, data }) => {
const { dispatch } = ownProps;
dispatch(
setRefetchAllFiles(data.refetch)
);
return {
data,
...ownProps,
};
}
}
)(FileListComponent);
虽然这有效,但我也收到警告,说:
Warning: setState(...): Cannot update during an existing state transition (such as within `render` or another component's constructor). Render methods should be a pure function of props and state; constructor side-effects are an anti-pattern, but can be moved to `componentWillMount`.
【问题讨论】:
标签: redux react-apollo