React Native

Forms & Validation

React Hook Form, Formik, Yup validation, controlled vs uncontrolled inputs, error handling

18 gespreksvragen·
Mid-Level
1

What is the main difference between a controlled and an uncontrolled input in React Native?

Antwoord

A controlled input is managed by React state via value and onChangeText props, allowing full control over the value at any time. An uncontrolled input uses a ref to directly access the DOM value without going through React state. Controlled inputs are recommended as they facilitate real-time validation and synchronization with the application state.

2

Which React Hook Form hook is used to register an input and handle its validation?

Antwoord

The useForm hook from React Hook Form returns an object containing several methods and properties. The register method allows registering an input in the form and attaching validation rules to it. It returns the necessary props (onChange, onBlur, ref) to connect the input to the form management system.

3

How to define an email validation schema with Yup?

Antwoord

Yup uses a chainable API to define validation schemas. To validate an email, use yup.string() to define the type, then chain .email() for email format validation, and optionally .required() to make the field mandatory. This declarative approach allows creating readable and reusable validations.

4

In Formik, which prop is used to define the initial values of the form?

5

What is the main performance advantage of React Hook Form compared to Formik?

+15 gespreksvragen

Beheers React Native voor je volgende gesprek

Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.

Begin gratis