Skip to content

Commit

Permalink
Update name to useFormStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
josephsavona committed Jun 17, 2024
1 parent 62badab commit 4e63166
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 141 deletions.
13 changes: 0 additions & 13 deletions compiler/packages/babel-plugin-react-compiler/src/HIR/Globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
BuiltInArrayId,
BuiltInUseActionStateId,
BuiltInUseEffectHookId,
BuiltInUseFormStateId,
BuiltInUseInsertionEffectHookId,
BuiltInUseLayoutEffectHookId,
BuiltInUseOperatorId,
Expand Down Expand Up @@ -280,18 +279,6 @@ const REACT_APIS: Array<[string, BuiltInType]> = [
returnValueReason: ValueReason.State,
}),
],
[
"useFormState",
addHook(DEFAULT_SHAPES, {
positionalParams: [],
restParam: Effect.Freeze,
returnType: { kind: "Object", shapeId: BuiltInUseFormStateId },
calleeEffect: Effect.Read,
hookKind: "useFormState",
returnValueKind: ValueKind.Frozen,
returnValueReason: ValueReason.State,
}),
],
[
"useReducer",
addHook(DEFAULT_SHAPES, {
Expand Down
17 changes: 1 addition & 16 deletions compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1555,16 +1555,6 @@ export function isSetActionStateType(id: Identifier): boolean {
);
}

export function isUseFormStateType(id: Identifier): boolean {
return id.type.kind === "Object" && id.type.shapeId === "BuiltInUseFormState";
}

export function isSetFormStateType(id: Identifier): boolean {
return (
id.type.kind === "Function" && id.type.shapeId === "BuiltInSetFormState"
);
}

export function isUseReducerType(id: Identifier): boolean {
return id.type.kind === "Function" && id.type.shapeId === "BuiltInUseReducer";
}
Expand All @@ -1574,12 +1564,7 @@ export function isDispatcherType(id: Identifier): boolean {
}

export function isStableType(id: Identifier): boolean {
return (
isSetStateType(id) ||
isSetActionStateType(id) ||
isSetFormStateType(id) ||
isDispatcherType(id)
);
return isSetStateType(id) || isSetActionStateType(id) || isDispatcherType(id);
}

export function isUseEffectHookType(id: Identifier): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export type HookKind =
| "useContext"
| "useState"
| "useActionState"
| "useFormState"
| "useFormStatus"
| "useReducer"
| "useRef"
| "useEffect"
Expand Down Expand Up @@ -199,8 +199,6 @@ export const BuiltInUseStateId = "BuiltInUseState";
export const BuiltInSetStateId = "BuiltInSetState";
export const BuiltInUseActionStateId = "BuiltInUseActionState";
export const BuiltInSetActionStateId = "BuiltInSetActionState";
export const BuiltInUseFormStateId = "BuiltInUseFormState";
export const BuiltInSetFormStateId = "BuiltInSetFormState";
export const BuiltInUseRefId = "BuiltInUseRefId";
export const BuiltInRefValueId = "BuiltInRefValue";
export const BuiltInMixedReadonlyId = "BuiltInMixedReadonly";
Expand Down Expand Up @@ -421,25 +419,6 @@ addObject(BUILTIN_SHAPES, BuiltInUseActionStateId, [
],
]);

addObject(BUILTIN_SHAPES, BuiltInUseFormStateId, [
["0", { kind: "Poly" }],
[
"1",
addFunction(
BUILTIN_SHAPES,
[],
{
positionalParams: [],
restParam: Effect.Freeze,
returnType: PRIMITIVE_TYPE,
calleeEffect: Effect.Read,
returnValueKind: ValueKind.Primitive,
},
BuiltInSetFormStateId
),
],
]);

addObject(BUILTIN_SHAPES, BuiltInUseReducerId, [
["0", { kind: "Poly" }],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,20 @@ import { c as _c } from "react/compiler-runtime";
import { useActionState } from "react";

function Component() {
const $ = _c(2);
const $ = _c(1);
const [actionState, dispatchAction] = useActionState();
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = () => {
const onSubmitAction = () => {
dispatchAction();
};

t0 = <Foo onSubmitAction={onSubmitAction} />;
$[0] = t0;
} else {
t0 = $[0];
}
const onSubmitAction = t0;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <Foo onSubmitAction={onSubmitAction} />;
$[1] = t1;
} else {
t1 = $[1];
}
return t1;
return t0;
}

function Foo() {}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 4e63166

Please sign in to comment.