Skip to main content

Command Palette

Search for a command to run...

Self-review: Create a registration form - Advanced React

Updated
1 min read
Self-review: Create a registration form - Advanced React
D

A passionate full-stack developer from @ePlus.DEV

  1. When you need to change the password state, which is stored as an object with two properties, value and isTouched, how should you correctly use the setPassword state setter inside the onChange event handler?

    • setPassword({ ...password, value: e.target.value });

    • setPassword({ isTouched: false, value: e.target.value });

    • setPassword({ value: e.target.value });

  2. What’s the correct event prop you should use to determine when an input has been interacted with at least once?

    • onFocus

    • onBlur

    • onChange

  3. How do you prevent the default behavior of the form HTML tag in React when a submission event occurs?

    • By returning false from the onSubmit function prop that the form tag provides.

    • By calling preventDefault on the event object inside any onChange handler from an input tag.

    • By calling preventDefault on the event object inside the onSubmit function prop from the form tag.


More from this blog

E

ePlus.DEV - Exploring Technology with David Nguyen

1230 posts

A passionate full-stack developer from VIETNAM.