When is useActionState moving out of canary?
Unanswered
andrevenancio posted this in #help-forum
I'm able to do
I'm using "next": "^14.2.4".
import { useActionState } from 'react';
but when Iconsole.log(useActionState)I haveundefined`. I'm using "next": "^14.2.4".
9 Replies
Lakeland Terrier
I do not have the answer to your question. useFormState should be in the version you have if useActionState doesn't exist.
Yup. just annoyed I have to put my button in its own component to have access to the status:)
Lakeland Terrier
'use client'
// @ts-expect-error
import { useFormStatus } from 'react-dom'
import React from 'react'
interface FormButtonProps {
children: React.ReactNode;
}
export default function FormButton({ children }: FormButtonProps) {
const { pending } = useFormStatus();
return <button type="submit">
{children}
</button>
}@andrevenancio Yup. just annoyed I have to put my button in its own component to have access to the status:)
you will still have to do that. [the documentation of
useActionState](https://react.dev/reference/react/useActionState) doesn't cover isPending anymore, so there is no guarantee it will work in future versions. that's why useFormStatus is the way to go.I think that is just a documentation issue. The feature exists
So using useActionState will remove the need of having the button status on a separate component
semver works like this: if it's in the documentation, it's semvered, if it's not in the documentation, it's an internal feature and may be removed at any time without a major release.
it's pretty clear that not documenting
isPending is undocumented. you can use it as you wish, but if your app suddenly blows up after upgrading from react 19.0.0 to react 19.0.1, you can only blame yourself.it's pretty clear that not documenting
isPending is an intentional decision on their part. it's not an oversight, they quite clearly decided to not semver this one.Lakeland Terrier
That is unfortunate, I have enjoyed my patterns with isPending.