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

85
Visualizações
props value showing undefined while component initial load : React

I have a react component with props like below. what i am trying to do is to set the default values to the dropdown when page loads. i tried this with a dummy array and it works fine. but when i pass the array via props from another component the value is not setting.

export interface dropdownProps {
  list: [];
  defaultSelectedList: number[];
}

// const defaultSelectedList = [123, 432, 987]; **this works if i set a dummy array** 
   console.log(defaultSelectedList, 'test');

const Dropdown: FC<DropdownProps> = (props) => {
 const methods = useForm<{ dropdown: number[] }>({
    defaultValues: {
      dropdown: defaultSelectedList
    },
  });
}


  <FormProvider {...methods}>
        <MultiSelect
          name="dropdown"
          list={list}
        />
   </FormProvider>

when i console the value initially the value is undefined and then the value is set. i am guess this could be the issue. can anyone help me with this enter image description here

about 4 years ago · Santiago Trujillo
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