Skip to content

Commit 31d53ea

Browse files
committed
Warn for useFormState on initial render
1 parent df783f9 commit 31d53ea

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
'use strict';
1212

1313
let React;
14-
let ReactDOM;
1514
let ReactTestRenderer;
1615
let ReactDebugTools;
1716
let act;
@@ -34,7 +33,6 @@ describe('ReactHooksInspectionIntegration', () => {
3433
jest.resetModules();
3534
React = require('react');
3635
ReactTestRenderer = require('react-test-renderer');
37-
ReactDOM = require('react-dom');
3836
act = require('internal-test-utils').act;
3937
ReactDebugTools = require('react-debug-tools');
4038
useMemoCache = require('react/compiler-runtime').c;
@@ -2658,9 +2656,9 @@ describe('ReactHooksInspectionIntegration', () => {
26582656
});
26592657

26602658
// @gate enableAsyncActions
2661-
it('should support useFormState hook', async () => {
2659+
it('should support useActionState hook', async () => {
26622660
function Foo() {
2663-
const [value] = ReactDOM.useFormState(function increment(n) {
2661+
const [value] = React.useActionState(function increment(n) {
26642662
return n;
26652663
}, 0);
26662664
React.useMemo(() => 'memo', []);
@@ -2689,7 +2687,7 @@ describe('ReactHooksInspectionIntegration', () => {
26892687
},
26902688
"id": 0,
26912689
"isStateEditable": false,
2692-
"name": "FormState",
2690+
"name": "ActionState",
26932691
"subHooks": [],
26942692
"value": 0,
26952693
},

packages/react-reconciler/src/ReactFiberHooks.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,6 +3994,7 @@ if (__DEV__) {
39943994
): [Awaited<S>, (P) => void, boolean] {
39953995
currentHookNameInDev = 'useFormState';
39963996
mountHookTypesDev();
3997+
warnOnUseFormStateInDev();
39973998
return mountActionState(action, initialState, permalink);
39983999
};
39994000
(HooksDispatcherOnMountInDEV: Dispatcher).useActionState =

packages/react-server-dom-webpack/src/__tests__/ReactFlightDOMForm-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ describe('ReactFlightDOMForm', () => {
7373
ReactDOMClient = require('react-dom/client');
7474
act = React.act;
7575

76-
if (__VARIANT__) {
77-
// Remove after API is deleted.
78-
useActionState = require('react-dom').useFormState;
79-
} else {
80-
useActionState = require('react').useActionState;
81-
}
76+
// TODO: Test the old api but it warns so needs warnings to be asserted.
77+
// if (__VARIANT__) {
78+
// Remove after API is deleted.
79+
// useActionState = require('react-dom').useFormState;
80+
// }
81+
useActionState = require('react').useActionState;
8282
container = document.createElement('div');
8383
document.body.appendChild(container);
8484
});

0 commit comments

Comments
 (0)