title: Pagination API + Deleting
body: <pre><code>const initialState = {
      getItemsLoading: true,
      posts: [],
      page: 1,
      pages: 0,
      totalPosts: 0
  }
  </code></pre>
  <pre><code>const App = ({ match }) =&gt; {
    const pageNumber = match.params.pageNumber || 1;
  
    const [page, setPage] = useState(pageNumber);
  
    useEffect(() =&gt; {
          console.log(&quot;CALLING API&quot;)
          dispatch(getPosts(
              {
                  page
              }
          ))
      }, [page, dispatch]);
  
      fecthPosts();
    }, [page]);
  </code></pre>
  <p>Using a YT tutorial as a foundation, I implemented a API pagination; however, I'm currently stuck on handling deleting a post.</p>
  <p>What is the approach to re-fetching the page when a post is deleted?</p>
  <p>Should I have something like this?</p>
  <pre><code>const onDelete() =&gt; {
     dispatch(deletePost(post._id))
     dispatch(fetchPosts(page))
  }
  </code></pre>
  <p>Is the above approach fine, or will there be race conditions, where post that is being deleted is re-fetched?</p>
  <p>I.e I should do something like this where I combine the API request into a single dispatch where</p>
  <pre><code>const deletePost = (post._id, page) =&gt; async (dispatch) =&gt; {
    // delete post
    // waits for post to be deleted then refetch data
  }
  </code></pre>
  <p>Although it seems a little bit weird passing in a page as a parameter.</p>