Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

420
Vistas
TypeError: Cannot destructure property 'control' of 'Object(...)(...)' as it is null

I am trying this for so long and it's not been working for 2 days now. Did some research but now I have no option other than to ask the community.

import { multiStepContext } from '../StepContext';
export default function BasicStep() {
  const {
    setStep,
    userData,
    setUserData,
    firstName,
    lastName,
    setfirstName,
    setlastName,
    username,
    title,
    cnicNo,
    gender,
    dob,
    referredBy,
    // country,
    cityId,
    state,
    profilePicture,
    setUsername,
    settitle,
    setcnicNo,
    setDob,
    // setCountry,
    // setState,
    setprofilePicture,
    setcityId,
    countryId,
    setcountryId,
    setreferredBy,
    stateId,
    setstateId,
    setGender
  } = useContext(multiStepContext);

  const {
    control,
    formState: { errors }
  } = useFormContext();

I want to add validation in a form like if nothing is entered the field goes red and ask for input.

<Controller
              control={control}
              name='firstName'
              rules={{
                required: true
                // type: 'email'
              }}
              render={({ field }) => (
    <TextField
                label='First Name'
                value={userData[firstName]}
                onChange={(e) => setfirstName(e.target.value)}
                margin='normal'
                defaultValue={userData[firstName]}
                fullWidth
                variant='outlined'
                {...field}
                error={errors.firstName}
              />

This is a multi-stepper form and the button is below

<Button onClick={() => setStep(2)} variant='contained' color='primary'>
          Next
        </Button>
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda