Skip to content

Commit

Permalink
Update React from f1039be4a to 60a927d04 (#60619)
Browse files Browse the repository at this point in the history
Includes a fix for useOptimistic.

React upstream changes:

- facebook/react#27936
- facebook/react#27924
- facebook/react#27930
- facebook/react#27923
- facebook/react#27922
- facebook/react#27917
- facebook/react#27916
- facebook/react#27918
- facebook/react#27919
- facebook/react#27914
- facebook/react#27911
- facebook/react#27909
- facebook/react#27907
- facebook/react#27906
- facebook/react#27905

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


Closes NEXT-2096
  • Loading branch information
acdlite committed Jan 14, 2024
1 parent 2bc2425 commit dc69724
Show file tree
Hide file tree
Showing 75 changed files with 4,489 additions and 3,447 deletions.
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,16 +197,16 @@
"random-seed": "0.3.0",
"react": "18.2.0",
"react-17": "npm:react@17.0.2",
"react-builtin": "npm:react@18.3.0-canary-f1039be4a-20240107",
"react-builtin": "npm:react@18.3.0-canary-60a927d04-20240113",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-canary-f1039be4a-20240107",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-f1039be4a-20240107",
"react-experimental-builtin": "npm:react@0.0.0-experimental-f1039be4a-20240107",
"react-server-dom-turbopack": "18.3.0-canary-f1039be4a-20240107",
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-f1039be4a-20240107",
"react-server-dom-webpack": "18.3.0-canary-f1039be4a-20240107",
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-f1039be4a-20240107",
"react-dom-builtin": "npm:react-dom@18.3.0-canary-60a927d04-20240113",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-60a927d04-20240113",
"react-experimental-builtin": "npm:react@0.0.0-experimental-60a927d04-20240113",
"react-server-dom-turbopack": "18.3.0-canary-60a927d04-20240113",
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-60a927d04-20240113",
"react-server-dom-webpack": "18.3.0-canary-60a927d04-20240113",
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-60a927d04-20240113",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand All @@ -216,8 +216,8 @@
"resolve-from": "5.0.0",
"sass": "1.54.0",
"satori": "0.10.9",
"scheduler-builtin": "npm:scheduler@0.24.0-canary-f1039be4a-20240107",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-f1039be4a-20240107",
"scheduler-builtin": "npm:scheduler@0.24.0-canary-60a927d04-20240113",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-60a927d04-20240113",
"seedrandom": "3.0.5",
"selenium-webdriver": "4.0.0-beta.4",
"semver": "7.3.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (process.env.NODE_ENV !== "production") {
var React = require("next/dist/compiled/react-experimental");
var ReactDOM = require('react-dom');

var ReactVersion = '18.3.0-experimental-f1039be4a-20240107';
var ReactVersion = '18.3.0-experimental-60a927d04-20240113';

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -6673,22 +6673,22 @@ function getWrappedName(outerType, innerType, wrapperName) {

function getContextName(type) {
return type.displayName || 'Context';
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
}

var REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference'); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.

function getComponentNameFromType(type) {
if (type == null) {
// Host root, text node or just invalid type.
return null;
}

{
if (typeof type.tag === 'number') {
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
if (typeof type === 'function') {
if (type.$$typeof === REACT_CLIENT_REFERENCE) {
// TODO: Create a convention for naming client references with debug info.
return null;
}
}

if (typeof type === 'function') {
return type.displayName || type.name || null;
}

Expand Down Expand Up @@ -6723,6 +6723,12 @@ function getComponentNameFromType(type) {
}

if (typeof type === 'object') {
{
if (typeof type.tag === 'number') {
error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
}
}

switch (type.$$typeof) {
case REACT_CONTEXT_TYPE:
var context = type;
Expand Down Expand Up @@ -9415,7 +9421,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
errorDigest = logRecoverableError(request, error, thrownInfo);
}

encodeErrorForBoundary(newBoundary, errorDigest, error, thrownInfo); // We don't need to decrement any task numbers because we didn't spawn any new task.
encodeErrorForBoundary(newBoundary, errorDigest, error, thrownInfo);
untrackBoundary(request, newBoundary); // We don't need to decrement any task numbers because we didn't spawn any new task.
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
Expand Down Expand Up @@ -10596,6 +10603,36 @@ function trackPostpone(request, trackedPostpones, task, segment) {

slots[task.childIndex] = segment.id;
}
} // In case a boundary errors, we need to stop tracking it because we won't
// resume it.


function untrackBoundary(request, boundary) {
var trackedPostpones = request.trackedPostpones;

if (trackedPostpones === null) {
return;
}

var boundaryKeyPath = boundary.trackedContentKeyPath;

if (boundaryKeyPath === null) {
return;
}

var boundaryNode = trackedPostpones.workingMap.get(boundaryKeyPath);

if (boundaryNode === undefined) {
return;
} // Downgrade to plain ReplayNode since we won't replay through it.
// $FlowFixMe[cannot-write]: We intentionally downgrade this to the other tuple.


boundaryNode.length = 4; // Remove any resumable slots.

boundaryNode[2] = [];
boundaryNode[3] = null; // TODO: We should really just remove the boundary from all parent paths too so
// we don't replay the path to it.
}

function injectPostponedHole(request, task, reason, thrownInfo) {
Expand Down Expand Up @@ -10814,7 +10851,8 @@ function erroredTask(request, boundary, error, errorInfo) {

if (boundary.status !== CLIENT_RENDERED) {
boundary.status = CLIENT_RENDERED;
encodeErrorForBoundary(boundary, errorDigest, error, errorInfo); // Regardless of what happens next, this boundary won't be displayed,
encodeErrorForBoundary(boundary, errorDigest, error, errorInfo);
untrackBoundary(request, boundary); // Regardless of what happens next, this boundary won't be displayed,
// so we can flush it, if the parent already flushed.

if (boundary.parentFlushed) {
Expand Down Expand Up @@ -10978,6 +11016,7 @@ function abortTask(task, request, error) {
}

encodeErrorForBoundary(boundary, _errorDigest, errorMessage, _errorInfo);
untrackBoundary(request, boundary);

if (boundary.parentFlushed) {
request.clientRenderedBoundaries.push(boundary);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function formatProdErrorMessage(code) {
return "Minified React error #" + code + "; visit " + url + " for the full message or " + 'use the non-minified dev environment for full errors and additional ' + 'helpful warnings.';
}

var ReactVersion = '18.3.0-experimental-f1039be4a-20240107';
var ReactVersion = '18.3.0-experimental-60a927d04-20240113';

// A pure JS implementation of a string hashing function. We do not use it for
// security or obfuscation purposes, only to create compact hashes. So we
Expand Down Expand Up @@ -4994,8 +4994,9 @@ function getWrappedName(outerType, innerType, wrapperName) {

function getContextName(type) {
return type.displayName || 'Context';
} // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
}

const REACT_CLIENT_REFERENCE = Symbol.for('react.client.reference'); // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.

function getComponentNameFromType(type) {
if (type == null) {
Expand All @@ -5004,6 +5005,11 @@ function getComponentNameFromType(type) {
}

if (typeof type === 'function') {
if (type.$$typeof === REACT_CLIENT_REFERENCE) {
// TODO: Create a convention for naming client references with debug info.
return null;
}

return type.displayName || type.name || null;
}

Expand Down Expand Up @@ -5038,6 +5044,7 @@ function getComponentNameFromType(type) {
}

if (typeof type === 'object') {

switch (type.$$typeof) {
case REACT_CONTEXT_TYPE:
const context = type;
Expand Down Expand Up @@ -6995,7 +7002,8 @@ function renderSuspenseBoundary(request, someTask, keyPath, props) {
errorDigest = logRecoverableError(request, error, thrownInfo);
}

encodeErrorForBoundary(newBoundary, errorDigest); // We don't need to decrement any task numbers because we didn't spawn any new task.
encodeErrorForBoundary(newBoundary, errorDigest);
untrackBoundary(request, newBoundary); // We don't need to decrement any task numbers because we didn't spawn any new task.
// We don't need to schedule any task because we know the parent has written yet.
// We do need to fallthrough to create the fallback though.
} finally {
Expand Down Expand Up @@ -7994,6 +8002,36 @@ function trackPostpone(request, trackedPostpones, task, segment) {

slots[task.childIndex] = segment.id;
}
} // In case a boundary errors, we need to stop tracking it because we won't
// resume it.


function untrackBoundary(request, boundary) {
const trackedPostpones = request.trackedPostpones;

if (trackedPostpones === null) {
return;
}

const boundaryKeyPath = boundary.trackedContentKeyPath;

if (boundaryKeyPath === null) {
return;
}

const boundaryNode = trackedPostpones.workingMap.get(boundaryKeyPath);

if (boundaryNode === undefined) {
return;
} // Downgrade to plain ReplayNode since we won't replay through it.
// $FlowFixMe[cannot-write]: We intentionally downgrade this to the other tuple.


boundaryNode.length = 4; // Remove any resumable slots.

boundaryNode[2] = [];
boundaryNode[3] = null; // TODO: We should really just remove the boundary from all parent paths too so
// we don't replay the path to it.
}

function injectPostponedHole(request, task, reason, thrownInfo) {
Expand Down Expand Up @@ -8210,7 +8248,8 @@ function erroredTask(request, boundary, error, errorInfo) {

if (boundary.status !== CLIENT_RENDERED) {
boundary.status = CLIENT_RENDERED;
encodeErrorForBoundary(boundary, errorDigest); // Regardless of what happens next, this boundary won't be displayed,
encodeErrorForBoundary(boundary, errorDigest);
untrackBoundary(request, boundary); // Regardless of what happens next, this boundary won't be displayed,
// so we can flush it, if the parent already flushed.

if (boundary.parentFlushed) {
Expand Down Expand Up @@ -8348,6 +8387,7 @@ function abortTask(task, request, error) {
const errorDigest = logRecoverableError(request, error, errorInfo);

encodeErrorForBoundary(boundary, errorDigest);
untrackBoundary(request, boundary);

if (boundary.parentFlushed) {
request.clientRenderedBoundaries.push(boundary);
Expand Down

0 comments on commit dc69724

Please sign in to comment.