Skip to content

Commit

Permalink
Warn for useFormState on initial render
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Jul 8, 2024
1 parent df783f9 commit f6f9190
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'use strict';

let React;
let ReactDOM;
let ReactTestRenderer;
let ReactDebugTools;
let act;
Expand All @@ -34,7 +33,6 @@ describe('ReactHooksInspectionIntegration', () => {
jest.resetModules();
React = require('react');
ReactTestRenderer = require('react-test-renderer');
ReactDOM = require('react-dom');
act = require('internal-test-utils').act;
ReactDebugTools = require('react-debug-tools');
useMemoCache = require('react/compiler-runtime').c;
Expand Down Expand Up @@ -2658,9 +2656,9 @@ describe('ReactHooksInspectionIntegration', () => {
});

// @gate enableAsyncActions
it('should support useFormState hook', async () => {
it('should support useActionState hook', async () => {
function Foo() {
const [value] = ReactDOM.useFormState(function increment(n) {
const [value] = React.useActionState(function increment(n) {
return n;
}, 0);
React.useMemo(() => 'memo', []);
Expand Down Expand Up @@ -2689,7 +2687,7 @@ describe('ReactHooksInspectionIntegration', () => {
},
"id": 0,
"isStateEditable": false,
"name": "FormState",
"name": "ActionState",
"subHooks": [],
"value": 0,
},
Expand Down
1 change: 1 addition & 0 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3994,6 +3994,7 @@ if (__DEV__) {
): [Awaited<S>, (P) => void, boolean] {
currentHookNameInDev = 'useFormState';
mountHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState, permalink);
};
(HooksDispatcherOnMountInDEV: Dispatcher).useActionState =
Expand Down

0 comments on commit f6f9190

Please sign in to comment.