Next.js Discord

Discord Forum

How to use toasts with useActionState?

Answered
Southern rough shrimp posted this in #help-forum
Open in Discord
Avatar
Southern rough shrimpOP
I'd like to create a toast whenever the action has finished, either successfully or not. The action already returns if it was successful or not, but not sure how you're meant to handle it now you just plug the action into the React hook
Image
Answered by B33fb0n3
you can check the formState inside a useEffect like this:
useEffect(() => {
  // work with your formstate
  toast("something happend to formState")
}, [formState])
View full answer

1 Reply

Avatar
you can check the formState inside a useEffect like this:
useEffect(() => {
  // work with your formstate
  toast("something happend to formState")
}, [formState])
Answer