クエリが終了した直後にリベンクスアクションをディスパッチしたい。 - これを行う正しい場所はどこですか?アポロ反応クエリー後のアクションのディスパッチ
ここでは、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`.