title: Android Paging 3 library loading infinitely without scroll with Jetpack Compose
body: <p>I'm attempting to make a paged list of books using Jetpack Compose and Android's Paging 3 library.  I am able to make the paged list and get the data fine, but the <code>load()</code> function of my paging data source is being called infinitely, without me scrolling the screen.</p>
  <p>My paging data source looks like this:</p>
  <pre><code>class GoogleBooksBookSource @Inject constructor(
      private val googleBooksRepository: GoogleBooksRepository,
      private val query: String
  ): PagingSource&lt;Int, Book&gt;() {
  
      override suspend fun load(params: LoadParams&lt;Int&gt;): LoadResult&lt;Int, Book&gt; {
          val position = params.key ?: 0
          return try {
              val response = googleBooksRepository.searchForBookStatic(query, position)
              if (response is Result.Success) {
                  LoadResult.Page(
                      data = response.data.items,
                      prevKey = if (position == 0) null else position - 1,
                      nextKey = if (response.data.totalItems == 0) null else position + 1
                  )
              } else {
                  LoadResult.Error(Exception(&quot;Error loading paged data&quot;))
              }
          } catch (e: Exception) {
              Log.e(&quot;PagingError&quot;, e.message.toString())
              return LoadResult.Error(e)
          }
      }
  
      override fun getRefreshKey(state: PagingState&lt;Int, Book&gt;): Int? {
          return state.anchorPosition?.let { anchorPosition -&gt;
              val anchorPage = state.closestPageToPosition(anchorPosition)
              anchorPage?.prevKey?.plus(1) ?: anchorPage?.nextKey?.minus(1)
          }
      }
  }
  </code></pre>
  <p>and this is the UI:</p>
  <pre><code>Column() {
      // other stuff
      LazyColumn(
          modifier = Modifier.padding(horizontal = 24.dp),
          content = {
              for (i in 0 until searchResults.itemCount) {
                  searchResults[i]?.let { book -&gt;
                      item {
                          BookCard(
                              book = book,
                              navigateToBookDetail = { navigateToBookDetail(book.id) }
                          )
                      }
                  }
              }
          }
      )
  }
  </code></pre>
  <p>As far as I can tell, the data loads correctly and in the correct order, but when I log the API request URLs, it's making infinite calls with an increasing <code>startIndex</code> each time.  That would be fine if I was scrolling, since Google Books searches often return thousands of results, but it does this even if I don't scroll the screen.</p>