Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make usePaginationFragment compatible with <Activity>
Summary: Fixes several issues with `usePaginationFragment()` to make it compatible with unstable `<Activity>` API. The motivating bug was as follows: * Load some component with pagination inside an `<Activity>` * Call loadNext() * While the request is still pending, hide the Activity component * (request completes) * Reveal the Activity component again In this case the ideal behavior is that the component observes the pagination results when it is revealed and `hasNext` reflects the correct value. However, what was happening is that the fetch was being unsubscribed at the network level on unmount (or in this case, on detach), such that the results were never even written into the store. As the bug demonstrates, cancelling work in "unmount" can leave a component in an inconsistent state. For example, the component might internally set state to track that it is pending and therefore not attempt to initiate any more fetches. There are a few approaches - uses actions is one - but the fix here is to simply not cancel the fetch on unmount, in case it's actually just a detach. We continue to write the new results to the store and call internal and user callbacks so that the component state can update in sync with the updated store state. Reviewed By: tyao1 Differential Revision: D62474325 fbshipit-source-id: 66fa4522cda7897c56dd77ad4c13a4382f5f15db
- Loading branch information