Skip to content

Commit f313bf4

Browse files
committed
Warn if className is specified with a rename suggestion
1 parent 03eb7d3 commit f313bf4

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

+21
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export let didWarnAboutReassigningProps: boolean;
322322
let didWarnAboutRevealOrder;
323323
let didWarnAboutTailOptions;
324324
let didWarnAboutDefaultPropsOnFunctionComponent;
325+
let didWarnAboutClassNameOnViewTransition;
325326

326327
if (__DEV__) {
327328
didWarnAboutBadClass = ({}: {[string]: boolean});
@@ -332,6 +333,7 @@ if (__DEV__) {
332333
didWarnAboutRevealOrder = ({}: {[empty]: boolean});
333334
didWarnAboutTailOptions = ({}: {[string]: boolean});
334335
didWarnAboutDefaultPropsOnFunctionComponent = ({}: {[string]: boolean});
336+
didWarnAboutClassNameOnViewTransition = ({}: {[string]: boolean});
335337
}
336338

337339
export function reconcileChildren(
@@ -3295,6 +3297,25 @@ function updateViewTransition(
32953297
pushMaterializedTreeId(workInProgress);
32963298
}
32973299
}
3300+
if (__DEV__) {
3301+
// $FlowFixMe[prop-missing]
3302+
if (pendingProps.className !== undefined) {
3303+
const example =
3304+
typeof pendingProps.className === 'string'
3305+
? JSON.stringify(pendingProps.className)
3306+
: '{...}';
3307+
if (!didWarnAboutClassNameOnViewTransition[example]) {
3308+
didWarnAboutClassNameOnViewTransition[example] = true;
3309+
console.error(
3310+
'<ViewTransition> doesn\'t accept a "className" prop. It has been renamed to "default".\n' +
3311+
'- <ViewTransition className=%s>\n' +
3312+
'+ <ViewTransition default=%s>',
3313+
example,
3314+
example,
3315+
);
3316+
}
3317+
}
3318+
}
32983319
if (current !== null && current.memoizedProps.name !== pendingProps.name) {
32993320
// If the name changes, we schedule a ref effect to create a new ref instance.
33003321
workInProgress.flags |= Ref | RefStatic;

0 commit comments

Comments
 (0)