Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Челендж: Створення Компонента Форми | React Хуки та Контекст
Опановуємо React
course content

Зміст курсу

Опановуємо React

Опановуємо React

4. React в Реальному Світі

Челендж: Створення Компонента Форми

Завдання

У цьому завданні вам потрібно створити компонент Form з двома полями вводу: email та password. Мета полягає у використанні хука useRef для посилання на елементи вводу та обробки логіки відправки форми.

Інструкції

  1. Імпортуйте хук useRef з бібліотеки react.
  2. Усередині компонента Form оголосіть дві змінні useRef: emailRef та passwordRef, ініціалізовані null.
  3. Обнуліть поля введення, встановивши їх значення в порожній рядок за допомогою змінних useRef.
  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 ( "" ).

Все було зрозуміло?

Секція 3. Розділ 5
We're sorry to hear that something went wrong. What happened?
some-alt