Actions to reduce dispatch after apollo response request

I want to send the reducex action right after the request completes. “Where would be a suitable place for this?”

here I save the link to the function refetch, so I can easily update the view with the latest data at a later point.

export default graphql(
    allFilesQuery,
    {
        props: ({ ownProps, data }) => {
            const { dispatch } = ownProps;
            dispatch(
                setRefetchAllFiles(data.refetch)
            );
            return {
                data,
                ...ownProps,
            };
        }
    }
)(FileListComponent);

while this works, I also get a warning saying:

Warning: setState(...): Cannot update during an existing state transition (such as within `render` or another component 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`.
+4
source share
1 answer

- . , setTimeout, , props , , , , , .

. componentWillReceiveProps ( ), , , . data.networkStatus data.loading .

+1

Source: https://habr.com/ru/post/1685221/


All Articles