Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Upgrade vendored react #62549

Merged
merged 3 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,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-a515d753b-20240220",
"react-builtin": "npm:react@18.3.0-canary-6c3b8dbfe-20240226",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-builtin": "npm:react-dom@18.3.0-canary-a515d753b-20240220",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-a515d753b-20240220",
"react-experimental-builtin": "npm:react@0.0.0-experimental-a515d753b-20240220",
"react-server-dom-turbopack": "18.3.0-canary-a515d753b-20240220",
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-a515d753b-20240220",
"react-server-dom-webpack": "18.3.0-canary-a515d753b-20240220",
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-a515d753b-20240220",
"react-dom-builtin": "npm:react-dom@18.3.0-canary-6c3b8dbfe-20240226",
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-6c3b8dbfe-20240226",
"react-experimental-builtin": "npm:react@0.0.0-experimental-6c3b8dbfe-20240226",
"react-server-dom-turbopack": "18.3.0-canary-6c3b8dbfe-20240226",
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-6c3b8dbfe-20240226",
"react-server-dom-webpack": "18.3.0-canary-6c3b8dbfe-20240226",
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-6c3b8dbfe-20240226",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand All @@ -217,8 +217,8 @@
"resolve-from": "5.0.0",
"sass": "1.54.0",
"satori": "0.10.9",
"scheduler-builtin": "npm:scheduler@0.24.0-canary-a515d753b-20240220",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-a515d753b-20240220",
"scheduler-builtin": "npm:scheduler@0.24.0-canary-6c3b8dbfe-20240226",
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-6c3b8dbfe-20240226",
"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 @@ -3,6 +3,7 @@ export let hydrationErrorComponentStack: string | undefined

// https://github.com/facebook/react/blob/main/packages/react-dom/src/__tests__/ReactDOMHydrationDiff-test.js used as a reference
const knownHydrationWarnings = new Set([
'Warning: In HTML, %s cannot be a descendant of <%s>.\nThis will cause a hydration error.%s',
'Warning: Text content did not match. Server: "%s" Client: "%s"%s',
'Warning: Expected server HTML to contain a matching <%s> in <%s>.%s',
'Warning: Expected server HTML to contain a matching text node for "%s" in <%s>.%s',
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-a515d753b-20240220';
var ReactVersion = '18.3.0-experimental-6c3b8dbfe-20240226';

var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;

Expand Down Expand Up @@ -74,9 +74,6 @@ function printWarning(level, format, args) {
}
}

// -----------------------------------------------------------------------------
var enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for

// ATTENTION
// When adding new symbols to this file,
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
Expand Down Expand Up @@ -615,6 +612,9 @@ function checkHtmlStringCoercion(value) {
}
}

// -----------------------------------------------------------------------------
var enableFloat = true; // Enables unstable_useMemoCache hook, intended as a compilation target for

// $FlowFixMe[method-unbinding]
var hasOwnProperty = Object.prototype.hasOwnProperty;

Expand Down Expand Up @@ -1510,6 +1510,7 @@ function validateProperty(tagName, name, value, eventRegistry) {

case 'defaultChecked':
case 'innerHTML':
case 'ref':
{
return true;
}
Expand Down Expand Up @@ -1933,7 +1934,7 @@ var clientRenderBoundary = '$RX=function(b,c,d,e){var a=document.getElementById(
var completeBoundary = '$RC=function(b,c,e){c=document.getElementById(c);c.parentNode.removeChild(c);var a=document.getElementById(b);if(a){b=a.previousSibling;if(e)b.data="$!",a.setAttribute("data-dgst",e);else{e=b.parentNode;a=b.nextSibling;var f=0;do{if(a&&8===a.nodeType){var d=a.data;if("/$"===d)if(0===f)break;else f--;else"$"!==d&&"$?"!==d&&"$!"!==d||f++}d=a.nextSibling;e.removeChild(a);a=d}while(a);for(;c.firstChild;)e.insertBefore(c.firstChild,a);b.data="$"}b._reactRetry&&b._reactRetry()}};';
var completeBoundaryWithStyles = '$RM=new Map;\n$RR=function(r,t,w){for(var u=$RC,n=$RM,p=new Map,q=document,g,b,h=q.querySelectorAll("link[data-precedence],style[data-precedence]"),v=[],k=0;b=h[k++];)"not all"===b.getAttribute("media")?v.push(b):("LINK"===b.tagName&&n.set(b.getAttribute("href"),b),p.set(b.dataset.precedence,g=b));b=0;h=[];var l,a;for(k=!0;;){if(k){var f=w[b++];if(!f){k=!1;b=0;continue}var c=!1,m=0;var d=f[m++];if(a=n.get(d)){var e=a._p;c=!0}else{a=q.createElement("link");a.href=d;a.rel="stylesheet";for(a.dataset.precedence=\nl=f[m++];e=f[m++];)a.setAttribute(e,f[m++]);e=a._p=new Promise(function(x,y){a.onload=x;a.onerror=y});n.set(d,a)}d=a.getAttribute("media");!e||"l"===e.s||d&&!matchMedia(d).matches||h.push(e);if(c)continue}else{a=v[b++];if(!a)break;l=a.getAttribute("data-precedence");a.removeAttribute("media")}c=p.get(l)||g;c===g&&(g=a);p.set(l,a);c?c.parentNode.insertBefore(a,c.nextSibling):(c=q.head,c.insertBefore(a,c.firstChild))}Promise.all(h).then(u.bind(null,r,t,""),u.bind(null,r,t,"Resource failed to load"))};';
var completeSegment = '$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};';
var formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'A React form was unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.getRootNode(),(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,\nd,b))}});';
var formReplaying = 'addEventListener("submit",function(a){if(!a.defaultPrevented){var c=a.target,d=a.submitter,e=c.action,b=d;if(d){var f=d.getAttribute("formAction");null!=f&&(e=f,b=null)}"javascript:throw new Error(\'React form unexpectedly submitted.\')"===e&&(a.preventDefault(),b?(a=document.createElement("input"),a.name=b.name,a.value=b.value,b.parentNode.insertBefore(a,b),b=new FormData(c),a.parentNode.removeChild(a)):b=new FormData(c),a=c.ownerDocument||c,(a.$$reactFormReplay=a.$$reactFormReplay||[]).push(c,d,b))}});';

function getValueDescriptorExpectingObjectForWarning(thing) {
return thing === null ? '`null`' : thing === undefined ? '`undefined`' : thing === '' ? 'an empty string' : "something with type \"" + typeof thing + "\"";
Expand Down Expand Up @@ -2540,7 +2541,7 @@ function makeFormFieldPrefix(resumableState) {


var actionJavaScriptURL = stringToPrecomputedChunk(escapeTextForBrowser( // eslint-disable-next-line no-script-url
"javascript:throw new Error('A React form was unexpectedly submitted.')"));
"javascript:throw new Error('React form unexpectedly submitted.')"));
var startHiddenInputChunk = stringToPrecomputedChunk('<input type="hidden"');

function pushAdditionalFormField(value, key) {
Expand Down Expand Up @@ -2717,6 +2718,7 @@ function pushAttribute(target, name, value) // not null or undefined

case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'ref':
// Ignored. These are built-in to React on the client.
return;

Expand Down Expand Up @@ -4469,6 +4471,7 @@ function pushStartCustomElement(target, props, tag) {

case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'ref':
// Ignored. These are built-in to React on the client.
break;

Expand Down Expand Up @@ -5750,6 +5753,7 @@ function writeStyleResourceAttributeInJS(destination, name, value) // not null o
case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'style':
case 'ref':
// Ignored
return;
// Attribute renames
Expand Down Expand Up @@ -5920,6 +5924,7 @@ function writeStyleResourceAttributeInAttr(destination, name, value) // not null
case 'suppressContentEditableWarning':
case 'suppressHydrationWarning':
case 'style':
case 'ref':
// Ignored
return;
// Attribute renames
Expand Down Expand Up @@ -7402,18 +7407,19 @@ var didWarnOnInvalidCallback;
didWarnOnInvalidCallback = new Set();
}

function warnOnInvalidCallback(callback, callerName) {
function warnOnInvalidCallback(callback) {
{
if (callback === null || typeof callback === 'function') {
return;
}
} // eslint-disable-next-line react-internal/safe-string-coercion


var key = callerName + '_' + callback;
var key = String(callback);

if (!didWarnOnInvalidCallback.has(key)) {
didWarnOnInvalidCallback.add(key);

error('%s(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callerName, callback);
error('Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
}
}
}
Expand Down Expand Up @@ -7442,7 +7448,7 @@ function warnNoop(publicInstance, callerName) {
return;
}

error('%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, callerName, componentName);
error('Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op.\n\nPlease check the code for the %s component.', callerName, componentName);

didWarnAboutNoopUpdateForComponent[warningKey] = true;
}
Expand All @@ -7463,7 +7469,7 @@ var classComponentUpdater = {

{
if (callback !== undefined && callback !== null) {
warnOnInvalidCallback(callback, 'setState');
warnOnInvalidCallback(callback);
}
}
}
Expand All @@ -7475,7 +7481,7 @@ var classComponentUpdater = {

{
if (callback !== undefined && callback !== null) {
warnOnInvalidCallback(callback, 'setState');
warnOnInvalidCallback(callback);
}
}
},
Expand All @@ -7488,7 +7494,7 @@ var classComponentUpdater = {
} else {
{
if (callback !== undefined && callback !== null) {
warnOnInvalidCallback(callback, 'setState');
warnOnInvalidCallback(callback);
}
}
}
Expand Down Expand Up @@ -7604,9 +7610,9 @@ function checkClassInstance(instance, ctor, newProps) {

if (!renderPresent) {
if (ctor.prototype && typeof ctor.prototype.render === 'function') {
error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
error('No `render` method found on the %s ' + 'instance: did you accidentally return an object from the constructor?', name);
} else {
error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
error('No `render` method found on the %s ' + 'instance: you may have forgotten to define `render`.', name);
}
}

Expand Down Expand Up @@ -7665,7 +7671,7 @@ function checkClassInstance(instance, ctor, newProps) {
var hasMutatedProps = instance.props !== newProps;

if (instance.props !== undefined && hasMutatedProps) {
error('%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
error('When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name);
}

if (instance.defaultProps) {
Expand Down Expand Up @@ -9984,7 +9990,7 @@ function validateFunctionComponentInDev(Component) {
{
if (Component) {
if (Component.childContextTypes) {
error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
error('childContextTypes cannot be defined on a function component.\n' + ' %s.childContextTypes = ...', Component.displayName || Component.name || 'Component');
}
}

Expand Down Expand Up @@ -10041,7 +10047,27 @@ function resolveDefaultProps(Component, baseProps) {
function renderForwardRef(request, task, keyPath, type, props, ref) {
var previousComponentStack = task.componentStack;
task.componentStack = createFunctionComponentStack(task, type.render);
var children = renderWithHooks(request, task, keyPath, type.render, props, ref);
var propsWithoutRef;

if ('ref' in props) {
// `ref` is just a prop now, but `forwardRef` expects it to not appear in
// the props object. This used to happen in the JSX runtime, but now we do
// it here.
propsWithoutRef = {};

for (var key in props) {
// Since `ref` should only appear in props via the JSX transform, we can
// assume that this is a plain object. So we don't need a
// hasOwnProperty check.
if (key !== 'ref') {
propsWithoutRef[key] = props[key];
}
}
} else {
propsWithoutRef = props;
}

var children = renderWithHooks(request, task, keyPath, type.render, propsWithoutRef, ref);
var hasId = checkDidRenderIdHook();
var formStateCount = getFormStateCount();
var formStateMatchingIndex = getFormStateMatchingIndex();
Expand Down Expand Up @@ -10433,7 +10459,16 @@ function renderNodeDestructive(request, task, node, childIndex) {
var type = element.type;
var key = element.key;
var props = element.props;
var ref = element.ref;
var ref;

{
// TODO: This is a temporary, intermediate step. Once the feature
// flag is removed, we should get the ref off the props object right
// before using it.
var refProp = props.ref;
ref = refProp !== undefined ? refProp : null;
}

var name = getComponentNameFromType(type);
var keyOrIndex = key == null ? childIndex === -1 ? 0 : childIndex : key;
var keyPath = [task.keyPath, name, keyOrIndex];
Expand Down