title: How to structure pagination state in Redux
body: <p><strong>TL;DR:</strong> How do you store pagination state in a Redux store given a large, normalized state tree with lots of resources, and multiple views displaying different paginated results?</p>
  
  <p>I'm wondering what is the best way to store pagination data in a Redux store. <a href="https://techblog.appnexus.com/five-tips-for-working-with-redux-in-large-applications-89452af4fdcb" rel="noreferrer">This article</a> prescribes storing pagination info as its own subtree within the state tree. I agree with that method, but here's where I disagree: the article suggests keying the pagination subtree by the type of resource being paginated, but what if there are several views that display paginated data of the same resource using different parameters? If you follow the article's method, your state tree may end up looking like this</p>
  
  <pre><code>{
    pagination: 
       todos: 
         count: 1000,
         nextPageUrl: ...,
         result: [list of id's]
       users:
         count: 200,
         nextPageUrl: ...,
         result: [list of id's]
  }
  </code></pre>
  
  <p>This doesn't seem to make sense to me if you have multiple ways to view the same resource. What if on one screen there are multiple tables displaying todos that were fetched using different parameters? For instance, one table displays todos that were fetched from <code>/api/todos/?userId=1</code> and another displays todos from <code>/api/todos/?userId=2</code>. </p>
  
  <p>Given the above problem, it seems that a solution for allowing more flexible pagination is to store pagination state on a per-component basis, rather than a per-entity basis. So your state could look something like this</p>
  
  <pre><code>{
    pagination:
      componentId:
         count: 1000,
         nextPageUrl: ...,
         result: [list of id's]
      anotherComponentId:
         count: 1000,
         nextPageUrl: ...,
         result: [list of id's]
  }
  </code></pre>
  
  <p>Of course, storing pagination results like this loses context as to what is being paginated. But is that so much of a problem? How do you go about paginating a large state tree with potentially multiple paginated results of the same resource? Thanks!</p>