Skip to content

Commit

Permalink
Warn when using useFormState (#28668)
Browse files Browse the repository at this point in the history
## Overview

useFormState has been replaced with useActionState. Warn when it's used.

Also removes the `experimental_useFormState` warnings.

DiffTrain build for [18812b6](18812b6)
  • Loading branch information
rickhanlonii committed Mar 29, 2024
1 parent aa4213f commit fc94889
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19c7c2929be68f87cfa6b7947c4ab9ffc5608e48
18812b645c93a9c42f931fae57bbbab9c1f402b8
25 changes: 24 additions & 1 deletion compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-classic-b7bec335";
var ReactVersion = "19.0.0-www-classic-9a163259";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -8988,11 +8988,13 @@ if (__DEV__) {
var didWarnUncachedGetSnapshot;
var didWarnAboutUseWrappedInTryCatch;
var didWarnAboutAsyncClientComponent;
var didWarnAboutUseFormState;

{
didWarnAboutMismatchedHooksForComponent = new Set();
didWarnAboutUseWrappedInTryCatch = new Set();
didWarnAboutAsyncClientComponent = new Set();
didWarnAboutUseFormState = new Set();
} // The effect "instance" is a shared object that remains the same for the entire
// lifetime of an effect. In Rust terms, a RefCell. We use it to store the
// "destroy" function that is returned from an effect, because that is stateful.
Expand Down Expand Up @@ -9135,6 +9137,24 @@ if (__DEV__) {
}
}

function warnOnUseFormStateInDev() {
{
var componentName = getComponentNameFromFiber(
currentlyRenderingFiber$1
);

if (!didWarnAboutUseFormState.has(componentName)) {
didWarnAboutUseFormState.add(componentName);

error(
"ReactDOM.useFormState has been deprecated and replaced by " +
"React.useActionState. Please update %s to use React.useActionState.",
componentName
);
}
}
}

function warnIfAsyncClientComponent(Component) {
{
// This dev-only check only works for detecting native async functions,
Expand Down Expand Up @@ -12224,6 +12244,7 @@ if (__DEV__) {
function useFormState(action, initialState, permalink) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState);
};

Expand Down Expand Up @@ -12388,6 +12409,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return updateActionState(action);
};

Expand Down Expand Up @@ -12557,6 +12579,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return rerenderActionState(action);
};

Expand Down
25 changes: 24 additions & 1 deletion compiled/facebook-www/ReactART-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ if (__DEV__) {
return self;
}

var ReactVersion = "19.0.0-www-modern-210281fd";
var ReactVersion = "19.0.0-www-modern-58f8023b";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -8753,11 +8753,13 @@ if (__DEV__) {
var didWarnUncachedGetSnapshot;
var didWarnAboutUseWrappedInTryCatch;
var didWarnAboutAsyncClientComponent;
var didWarnAboutUseFormState;

{
didWarnAboutMismatchedHooksForComponent = new Set();
didWarnAboutUseWrappedInTryCatch = new Set();
didWarnAboutAsyncClientComponent = new Set();
didWarnAboutUseFormState = new Set();
} // The effect "instance" is a shared object that remains the same for the entire
// lifetime of an effect. In Rust terms, a RefCell. We use it to store the
// "destroy" function that is returned from an effect, because that is stateful.
Expand Down Expand Up @@ -8900,6 +8902,24 @@ if (__DEV__) {
}
}

function warnOnUseFormStateInDev() {
{
var componentName = getComponentNameFromFiber(
currentlyRenderingFiber$1
);

if (!didWarnAboutUseFormState.has(componentName)) {
didWarnAboutUseFormState.add(componentName);

error(
"ReactDOM.useFormState has been deprecated and replaced by " +
"React.useActionState. Please update %s to use React.useActionState.",
componentName
);
}
}
}

function warnIfAsyncClientComponent(Component) {
{
// This dev-only check only works for detecting native async functions,
Expand Down Expand Up @@ -11989,6 +12009,7 @@ if (__DEV__) {
function useFormState(action, initialState, permalink) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState);
};

Expand Down Expand Up @@ -12153,6 +12174,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return updateActionState(action);
};

Expand Down Expand Up @@ -12322,6 +12344,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return rerenderActionState(action);
};

Expand Down
25 changes: 24 additions & 1 deletion compiled/facebook-www/ReactDOM-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13547,11 +13547,13 @@ if (__DEV__) {
var didWarnUncachedGetSnapshot;
var didWarnAboutUseWrappedInTryCatch;
var didWarnAboutAsyncClientComponent;
var didWarnAboutUseFormState;

{
didWarnAboutMismatchedHooksForComponent = new Set();
didWarnAboutUseWrappedInTryCatch = new Set();
didWarnAboutAsyncClientComponent = new Set();
didWarnAboutUseFormState = new Set();
} // The effect "instance" is a shared object that remains the same for the entire
// lifetime of an effect. In Rust terms, a RefCell. We use it to store the
// "destroy" function that is returned from an effect, because that is stateful.
Expand Down Expand Up @@ -13696,6 +13698,24 @@ if (__DEV__) {
}
}

function warnOnUseFormStateInDev() {
{
var componentName = getComponentNameFromFiber(
currentlyRenderingFiber$1
);

if (!didWarnAboutUseFormState.has(componentName)) {
didWarnAboutUseFormState.add(componentName);

error(
"ReactDOM.useFormState has been deprecated and replaced by " +
"React.useActionState. Please update %s to use React.useActionState.",
componentName
);
}
}
}

function warnIfAsyncClientComponent(Component) {
{
// This dev-only check only works for detecting native async functions,
Expand Down Expand Up @@ -16924,6 +16944,7 @@ if (__DEV__) {
function useFormState(action, initialState, permalink) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState);
};

Expand Down Expand Up @@ -17092,6 +17113,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return updateActionState(action);
};

Expand Down Expand Up @@ -17265,6 +17287,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return rerenderActionState(action);
};

Expand Down Expand Up @@ -36345,7 +36368,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-698b36f3";
var ReactVersion = "19.0.0-www-classic-eb2e3f4c";

function createPortal$1(
children,
Expand Down
25 changes: 24 additions & 1 deletion compiled/facebook-www/ReactDOM-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -13510,11 +13510,13 @@ if (__DEV__) {
var didWarnUncachedGetSnapshot;
var didWarnAboutUseWrappedInTryCatch;
var didWarnAboutAsyncClientComponent;
var didWarnAboutUseFormState;

{
didWarnAboutMismatchedHooksForComponent = new Set();
didWarnAboutUseWrappedInTryCatch = new Set();
didWarnAboutAsyncClientComponent = new Set();
didWarnAboutUseFormState = new Set();
} // The effect "instance" is a shared object that remains the same for the entire
// lifetime of an effect. In Rust terms, a RefCell. We use it to store the
// "destroy" function that is returned from an effect, because that is stateful.
Expand Down Expand Up @@ -13659,6 +13661,24 @@ if (__DEV__) {
}
}

function warnOnUseFormStateInDev() {
{
var componentName = getComponentNameFromFiber(
currentlyRenderingFiber$1
);

if (!didWarnAboutUseFormState.has(componentName)) {
didWarnAboutUseFormState.add(componentName);

error(
"ReactDOM.useFormState has been deprecated and replaced by " +
"React.useActionState. Please update %s to use React.useActionState.",
componentName
);
}
}
}

function warnIfAsyncClientComponent(Component) {
{
// This dev-only check only works for detecting native async functions,
Expand Down Expand Up @@ -16887,6 +16907,7 @@ if (__DEV__) {
function useFormState(action, initialState, permalink) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState);
};

Expand Down Expand Up @@ -17055,6 +17076,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return updateActionState(action);
};

Expand Down Expand Up @@ -17228,6 +17250,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return rerenderActionState(action);
};

Expand Down Expand Up @@ -36193,7 +36216,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-modern-05455d88";
var ReactVersion = "19.0.0-www-modern-0c956171";

function createPortal$1(
children,
Expand Down
25 changes: 24 additions & 1 deletion compiled/facebook-www/ReactDOMTesting-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13684,11 +13684,13 @@ if (__DEV__) {
var didWarnUncachedGetSnapshot;
var didWarnAboutUseWrappedInTryCatch;
var didWarnAboutAsyncClientComponent;
var didWarnAboutUseFormState;

{
didWarnAboutMismatchedHooksForComponent = new Set();
didWarnAboutUseWrappedInTryCatch = new Set();
didWarnAboutAsyncClientComponent = new Set();
didWarnAboutUseFormState = new Set();
} // The effect "instance" is a shared object that remains the same for the entire
// lifetime of an effect. In Rust terms, a RefCell. We use it to store the
// "destroy" function that is returned from an effect, because that is stateful.
Expand Down Expand Up @@ -13833,6 +13835,24 @@ if (__DEV__) {
}
}

function warnOnUseFormStateInDev() {
{
var componentName = getComponentNameFromFiber(
currentlyRenderingFiber$1
);

if (!didWarnAboutUseFormState.has(componentName)) {
didWarnAboutUseFormState.add(componentName);

error(
"ReactDOM.useFormState has been deprecated and replaced by " +
"React.useActionState. Please update %s to use React.useActionState.",
componentName
);
}
}
}

function warnIfAsyncClientComponent(Component) {
{
// This dev-only check only works for detecting native async functions,
Expand Down Expand Up @@ -17061,6 +17081,7 @@ if (__DEV__) {
function useFormState(action, initialState, permalink) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return mountActionState(action, initialState);
};

Expand Down Expand Up @@ -17229,6 +17250,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return updateActionState(action);
};

Expand Down Expand Up @@ -17402,6 +17424,7 @@ if (__DEV__) {
) {
currentHookNameInDev = "useFormState";
updateHookTypesDev();
warnOnUseFormStateInDev();
return rerenderActionState(action);
};

Expand Down Expand Up @@ -36969,7 +36992,7 @@ if (__DEV__) {
return root;
}

var ReactVersion = "19.0.0-www-classic-f4cfd755";
var ReactVersion = "19.0.0-www-classic-25663c8c";

function createPortal$1(
children,
Expand Down
Loading

0 comments on commit fc94889

Please sign in to comment.