@@ -178,10 +178,12 @@ let didWarnAboutMismatchedHooksForComponent;
178178let didWarnUncachedGetSnapshot : void | true ;
179179let didWarnAboutUseWrappedInTryCatch ;
180180let didWarnAboutAsyncClientComponent ;
181+ let didWarnAboutUseFormState ;
181182if ( __DEV__ ) {
182183 didWarnAboutMismatchedHooksForComponent = new Set < string | null > ( ) ;
183184 didWarnAboutUseWrappedInTryCatch = new Set < string | null > ( ) ;
184185 didWarnAboutAsyncClientComponent = new Set < string | null > ( ) ;
186+ didWarnAboutUseFormState = new Set < string | null > ( ) ;
185187}
186188
187189export type Hook = {
@@ -386,6 +388,21 @@ function warnOnHookMismatchInDev(currentHookName: HookType): void {
386388 }
387389}
388390
391+ function warnOnUseFormStateInDev ( ) : void {
392+ if ( __DEV__ ) {
393+ const componentName = getComponentNameFromFiber ( currentlyRenderingFiber ) ;
394+ if ( ! didWarnAboutUseFormState . has ( componentName ) ) {
395+ didWarnAboutUseFormState . add ( componentName ) ;
396+
397+ console . error (
398+ 'ReactDOM.useFormState has been deprecated and replaced by ' +
399+ 'React.useActionState. Please update %s to use React.useActionState.' ,
400+ componentName ,
401+ ) ;
402+ }
403+ }
404+ }
405+
389406function warnIfAsyncClientComponent ( Component : Function ) {
390407 if ( __DEV__ ) {
391408 // This dev-only check only works for detecting native async functions,
@@ -4000,6 +4017,7 @@ if (__DEV__) {
40004017 ) : [ Awaited < S > , ( P ) => void , boolean ] {
40014018 currentHookNameInDev = 'useFormState' ;
40024019 updateHookTypesDev ( ) ;
4020+ warnOnUseFormStateInDev ( ) ;
40034021 return mountActionState ( action , initialState , permalink ) ;
40044022 } ;
40054023 ( HooksDispatcherOnMountWithHookTypesInDEV : Dispatcher ) . useActionState =
@@ -4182,6 +4200,7 @@ if (__DEV__) {
41824200 ) : [ Awaited < S > , ( P ) => void , boolean ] {
41834201 currentHookNameInDev = 'useFormState' ;
41844202 updateHookTypesDev ( ) ;
4203+ warnOnUseFormStateInDev ( ) ;
41854204 return updateActionState ( action , initialState , permalink ) ;
41864205 } ;
41874206 ( HooksDispatcherOnUpdateInDEV : Dispatcher ) . useActionState =
@@ -4364,6 +4383,7 @@ if (__DEV__) {
43644383 ) : [ Awaited < S > , ( P ) => void , boolean ] {
43654384 currentHookNameInDev = 'useFormState' ;
43664385 updateHookTypesDev ( ) ;
4386+ warnOnUseFormStateInDev ( ) ;
43674387 return rerenderActionState ( action , initialState , permalink ) ;
43684388 } ;
43694389 ( HooksDispatcherOnRerenderInDEV : Dispatcher ) . useActionState =
0 commit comments