react-apollo icon indicating copy to clipboard operation
react-apollo copied to clipboard

onComplete being called on every render

Open vititu opened this issue 8 years ago • 8 comments

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.

vititu avatar Oct 21 '18 19:10 vititu

same problem.

geekplux avatar Nov 08 '18 14:11 geekplux

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

asgeirfri avatar Jan 16 '19 14:01 asgeirfri

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?

hcharley avatar Feb 14 '19 19:02 hcharley

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
              }
            }}
          >

JaosnHsieh avatar Mar 22 '19 08:03 JaosnHsieh

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

hwillson avatar Jun 15 '19 11:06 hwillson

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

hcharley avatar Jun 15 '19 11:06 hcharley

still happening actually...

kcvin94 avatar Sep 06 '19 08:09 kcvin94

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

dylanwulf avatar Sep 06 '19 13:09 dylanwulf