Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix hydration errors and stale data within the Pagination component #1283

Merged
merged 2 commits into from
Aug 29, 2023

Conversation

blittle
Copy link
Contributor

@blittle blittle commented Aug 29, 2023

WHY are these changes introduced?

The Pagination component has hydration errors because it uses useMemo instead of useEffect for updating history state. This makes the output of the server immediately mismatch what renders in the client. By using an effect instead, hydration has already taken place.

Also make sure that the Load previous and Load more are properly calculated.

QA steps:

  1. Boot up the demo store products page: http://localhost:3000/products
  2. Open up the console, make sure there aren't hydration errors.
  3. Click load more. More products should load.
  4. Refresh and make sure no hydration errors.
  5. Copy the link and open in an incognito window. A previous link should appear. Click it, previous products should load and the link should disappear. Refresh the page. No hydration errors should occur.
  6. Click load more, and more products should append.

WHAT is this pull request doing?

HOW to test your changes?

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

@blittle blittle merged commit 1b7e001 into main Aug 29, 2023
@blittle blittle deleted the bl-fix-pagination-hydration branch August 29, 2023 19:34
@DennisKraaijeveld
Copy link

@blittle I assume this caused filters to stop working on collection pages? Do we need to change something there?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants