@@ -82,6 +82,8 @@ let didWarnAboutLegacyLifecyclesAndDerivedState;
8282let didWarnAboutUndefinedDerivedState ;
8383let didWarnAboutDirectlyAssigningPropsToState ;
8484let didWarnAboutContextTypeAndContextTypes ;
85+ let didWarnAboutContextTypes ;
86+ let didWarnAboutChildContextTypes ;
8587let didWarnAboutInvalidateContextType ;
8688let didWarnOnInvalidCallback ;
8789
@@ -93,6 +95,8 @@ if (__DEV__) {
9395 didWarnAboutDirectlyAssigningPropsToState = new Set < string > ( ) ;
9496 didWarnAboutUndefinedDerivedState = new Set < string > ( ) ;
9597 didWarnAboutContextTypeAndContextTypes = new Set < string > ( ) ;
98+ didWarnAboutContextTypes = new Set < mixed > ( ) ;
99+ didWarnAboutChildContextTypes = new Set < mixed > ( ) ;
96100 didWarnAboutInvalidateContextType = new Set < string > ( ) ;
97101 didWarnOnInvalidCallback = new Set < string > ( ) ;
98102
@@ -385,14 +389,16 @@ function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
385389 }
386390
387391 if ( disableLegacyContext ) {
388- if ( ctor . childContextTypes ) {
392+ if ( ctor . childContextTypes && ! didWarnAboutChildContextTypes . has ( ctor ) ) {
393+ didWarnAboutChildContextTypes . add ( ctor ) ;
389394 console . error (
390395 '%s uses the legacy childContextTypes API which was removed in React 19. ' +
391396 'Use React.createContext() instead.' ,
392397 name ,
393398 ) ;
394399 }
395- if ( ctor . contextTypes ) {
400+ if ( ctor . contextTypes && ! didWarnAboutContextTypes . has ( ctor ) ) {
401+ didWarnAboutContextTypes . add ( ctor ) ;
396402 console . error (
397403 '%s uses the legacy contextTypes API which was removed in React 19. ' +
398404 'Use React.createContext() with static contextType instead.' ,
0 commit comments