Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

431
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda