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 [2ec2aae](2ec2aae)
  • Loading branch information
sebmarkbage committed Mar 27, 2024
1 parent 5add535 commit 1fc73fb
Show file tree
Hide file tree
Showing 10 changed files with 5,650 additions and 177 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f7aa5e0aa3e2aa51279af4b6cb5413912cacd7f5
2ec2aaea98588178525f83495669e11e96815a00
Loading

0 comments on commit 1fc73fb

Please sign in to comment.