Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Challenge: Creating a Form Component | React Hooks and Context
React Mastery
course content

Conteúdo do Curso

React Mastery

React Mastery

1. Introduction to React Fundamentals
2. Styling in React Apps
3. React Hooks and Context
4. React in the Real World

bookChallenge: Creating a Form Component

Task

In this challenge, you will create a Form component with two input fields: email and password. The goal is to use the useRef hook to reference the input elements and handle form submission logic.

Instructions

  1. Import the useRef hook from the react library.
  2. Inside the Form component, declare two useRef variables: emailRef and passwordRef, initialized with null.
  3. Reset the input fields by setting their values to an empty string using the useRef variables.
  1. To import the necessary hook from the React library, include an import statement.
  2. For this task, we will utilize the useRef hook to store data without affecting the markup.
  3. To determine the appropriate variable name for the ref, choose a word that is associated with the ref and add "Ref" at the end.
  4. To initialize the ref with null, pass null as the initial value in the brackets of the useRef hook (e.g., useRef(null)).
  5. To reset the form input, use the appropriate ref variable and assign its .current.value to an empty string ("").

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 5
We're sorry to hear that something went wrong. What happened?
some-alt