Skip to content

Commit

Permalink
Add Diffs to Hydration Warnings (#28512)
Browse files Browse the repository at this point in the history
Stacked on #28502.

This builds on the mechanism in #28502 by adding a diff of everything
we've collected so far to the thrown error or logged error.

This isn't actually a longest common subsequence diff. This means that
there are certain cases that can appear confusing such as a node being
added/removed when it really would've appeared later in the list. In
fact once a node mismatches, we abort rendering so we don't have the
context of what would've been rendered. It's not quite right to use the
result of the recovery render because it can use client-only code paths
using useSyncExternalStore which would yield false differences. That's
why diffing the HTML isn't quite right.

I also present abstract components in the stack, these are presented
with the client props and no diff since we don't have the props that
were on the server. The lack of difference might be confusing but it's
useful for context.

The main thing that's data new here is that we're adding some siblings
and props for context.

Examples in the [snapshot
commit](e14532f).

DiffTrain build for commit 2ec2aae.
  • Loading branch information
sebmarkbage committed Mar 27, 2024
1 parent f6aa145 commit f3180a2
Show file tree
Hide file tree
Showing 4 changed files with 1,978 additions and 13 deletions.
Loading

0 comments on commit f3180a2

Please sign in to comment.