Skip to content

Commit

Permalink
Use nocollapse to disable gcc JSCompilerOptimizeArgumentsArray
Browse files Browse the repository at this point in the history
  • Loading branch information
davesnx committed Dec 16, 2024
1 parent c497daf commit 963fb7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
12 changes: 8 additions & 4 deletions packages/react-dom/src/client/ReactDOMRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,19 @@ ReactDOMHydrationRoot.prototype.render = ReactDOMRoot.prototype.render =
}

if (__DEV__) {
if (typeof arguments[1] === 'function') {
// @nocollapse - avoid GCC optimizations affecting function arity
const args = arguments;
if (typeof args[1] === 'function') {
console.error(
'does not support the second callback argument. ' +
'To execute a side effect after rendering, declare it in a component body with useEffect().',
);
} else if (isValidContainer(arguments[1])) {
} else if (isValidContainer(args[1])) {
console.error(
'You passed a container to the second argument of root.render(...). ' +
"You don't need to pass it again since you already passed it to create the root.",
);
} else if (typeof arguments[1] !== 'undefined') {
} else if (typeof args[1] !== 'undefined') {
console.error(
'You passed a second argument to root.render(...) but it only accepts ' +
'one argument.',
Expand All @@ -131,7 +133,9 @@ ReactDOMHydrationRoot.prototype.unmount = ReactDOMRoot.prototype.unmount =
// $FlowFixMe[missing-this-annot]
function (): void {
if (__DEV__) {
if (typeof arguments[0] === 'function') {
// @nocollapse - avoid GCC optimizations affecting function arity
const args = arguments;
if (typeof args[0] === 'function') {
console.error(
'does not support a callback argument. ' +
'To execute a side effect after rendering, declare it in a component body with useEffect().',
Expand Down
8 changes: 6 additions & 2 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3644,7 +3644,9 @@ function dispatchReducerAction<S, A>(
action: A,
): void {
if (__DEV__) {
if (typeof arguments[3] === 'function') {
// @nocollapse - avoid GCC optimizations affecting function arity
const args = arguments;
if (typeof args[3] === 'function') {
console.error(
"State updates from the useState() and useReducer() Hooks don't support the " +
'second callback argument. To execute a side effect after ' +
Expand Down Expand Up @@ -3684,7 +3686,9 @@ function dispatchSetState<S, A>(
action: A,
): void {
if (__DEV__) {
if (typeof arguments[3] === 'function') {
// @nocollapse - avoid GCC optimizations affecting function arity
const args = arguments;
if (typeof args[3] === 'function') {
console.error(
"State updates from the useState() and useReducer() Hooks don't support the " +
'second callback argument. To execute a side effect after ' +
Expand Down

0 comments on commit 963fb7b

Please sign in to comment.