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

86
Vistas
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 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