I'm using react-hook-form and I came across ?. operator. What does it mean? Here is some context on how it's used
<span>{errors?.name?.message}</span>
Where errors is destructured from useForm() like so
const { register, handleSubmit, formState: { errors } } = useForm();
Here is a full form input to paint a clearer picture
<input
type="text"
id='name'
name='name'
{...register('name', {
required: {
value: true,
message: 'Name cannot be empty'
}
})}
placeholder='John Doe'
className='px-6 w-full rounded-md py-2 text-gray-700 focus:outline-none'
/>
<span>{errors?.name?.message}</span>