Coding task · JavaScript and React course · Module 9: Modern React Hooks

Practice: useActionState and useFormStatus

useFormStatus() from react-dom returns { pending, data, method, action } of the parent form, so it only works in a component rendered inside a <form>. That is why the button is a separate component.

Task

The report form for Mission Control uses useActionState, and the submit button is a separate SubmitButton component that should know by itself that the form is being sent. Fill in the blanks: ___BLANK1___ is the field returned by the hook that is true while sending, ___BLANK2___ is the react-dom hook that reads the state of the form the component is rendered in, ___BLANK3___ is the button component placed in the form, and ___BLANK4___ is the status the action returns for a report that is too short. A report shorter than 10 characters should show an error, a longer one a confirmation, and during the transmission the button should be disabled and change its label.