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

Practice: Space Mission Form

The action gets (previousState, formData) and returns the new state. useActionState(action, initialState) gives you [state, formAction, isPending]: pass formAction to the form's action attribute and use isPending to disable the button.

Task

App.jsx contains a mission report form and an async action sendReport, which checks the mission name and answers after half a second, like the base on Earth. Fill in the blanks: ___BLANK1___ is the FormData method that reads a field value by its name, ___BLANK2___ is the React 19 hook that connects the action with the form state and returns [state, formAction, isPending], ___BLANK3___ is the <form> attribute you pass formAction to, and ___BLANK4___ is the value that disables the button while the form is being sent. A name shorter than 3 characters should show an error message, a valid one a confirmation with the mission name. Submit the form in the preview and check both cases.