Skip to content

useFormState type errors with v7 #259

Closed Answered by TheEdoRan
benjick asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, the TS error should go away if you simply pass an empty object as the second parameter of useFormState. Safe action result is an object with optional properties; since you need to provide the initial state to useFormState, {} is all that's needed for the initial state:

export function BugDialog(props: BugDialogProps) {
- const [state, dispatch] = useFormState(createIssue, null);
+ const [state, dispatch] = useFormState(createIssue, {});
...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TheEdoRan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants