TanStackT
TanStack11mo ago
4 replies
spontaneous-moccasin

isSuccess signal is not triggering on infiniteQuery

    effect ( () => {

      console.log( this.query.isSuccess() );

      if ( this.needsFetching() && this.query.isSuccess() ) {

        this.needsFetching.set( false );

        this.query.fetchNextPage().then( console.log );

      } else if ( this.query.isSuccess() && this.isFirstLoad() ) {

        if ( ( window.innerHeight + window.scrollY) >= document.body.offsetHeight ) {

          this.query.fetchNextPage()

          //the isSuccess() signal should trigger back the effect after the request but doesn't

        } else {

          this.isFirstLoad.set( false );

        }

      }

    }, { allowSignalWrites:true })


this.isFirstLoad.set(false) is never triggered. I've tried changing the position of isSuccess() in the conditions but first part of the effect is getting triggered after scroll event but the second part is triggered after the default fetch.It is supposed to fetch enough requests to fill the window's height.Thank for your time and consideration.

as simple example would be to do something like this

effect( () => {
  query.isSuccess()
  query.fetchNextPage()
} )

here I would expect the effect to trigger infinitely but it doesn't
Was this page helpful?