Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

onComplete being called on every render #2522

Closed
vititu opened this issue Oct 21, 2018 · 8 comments
Closed

onComplete being called on every render #2522

vititu opened this issue Oct 21, 2018 · 8 comments

Comments

@vititu
Copy link

vititu commented Oct 21, 2018

The changes made related to issue #2177 causes onCompleted to be called on every render. Before it was called once.

That might break the app causing a Maximum update depth exceeded error if trying to setSate with the data provided.

@geekplux
Copy link

geekplux commented Nov 8, 2018

same problem.

@asgeirfri
Copy link

Does anyone know the propper way to only setState after server call? Thanks.

@hcharley
Copy link

This is happening to me as well.

This seems to be functioning differently from what I understand the intended behavior of onCompleted to be.

Any hints as to why this is happening?

@JaosnHsieh
Copy link

you can add an if else condition in completed function in order to prevent what will change state again and again.

       <Query
            query={XXXXX}
            onCompleted={(data) => {
              if (!initValue) {
                   ...do something
              }
            }}
          >

@hwillson
Copy link
Member

This has been fixed in current day versions of react-apollo. Thanks!

@hcharley
Copy link

That's great! @hwillson Thank you for updating this ticket!

@kcvin94
Copy link

kcvin94 commented Sep 6, 2019

still happening actually...

@dylanwulf
Copy link
Contributor

@kcvin94 Should be fixed in the newly released v3.1.0. See #3353 for more details.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants