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

213
Vistas
(React) Setting a default value for a dropdown list based on the global state

I have a landing page and a search page. The landing page has radio buttons that change the global state of boolean values. The idea is when I hit the search button on the landing, the app will take me to the search page with a dropdown list. I want the dropdown list's default value to be what was selected back on the landing page

  function getServiceDropdown(){
if (props.houseSitting) {
  return "isHome"
} else if (props.dropInVisits) {
  return "isVisit"
}

<select defaultValue={getServiceDropdown}>
  <option>Boarding</option>
  <option value="isHome">Home Sitting</option>
  <option value="isVisit">Drop-in Visits</option>
  <option>Day Care</option>
  <option>Dog Walking</option>
</select>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

State Block is heere for class componnent

    this.state = {
        bloodTypes: [
            { value: "Seçiniz", name: "Choose" },
            { value: "0 RH -", name: "0 RH -" },
            { value: "0 RH +", name: "0 RH +" },
            { value: "A RH -", name: "A RH -" },
            { value: "A RH +", name: "A RH +" },
            { value: "B RH -", name: "B RH -" },
            { value: "B RH +", name: "B RH +" },
            { value: "AB RH -", name: "AB RH -" },
            { value: "AB RH +", name: "AB RH +" },
        ],

On Change function is heere for class componnent

onChangeData = (type, event) => {

    const stateData = this.state;
    if (event === "" || event === "Choose")
        stateData[type] = undefined
    else
        stateData[type] = event

    this.setState({ stateData });
}

Select option component is heere for class componnent

   <select value={this.state.bloodType} onChange={e => 
         this.onChangeData("bloodType", e.target.value)}>
        {this.state.bloodTypes.map((type, index) =>
            <option 
                key={index} 
                value={type.value}>{type.name}</option>
        )
    } 
    </select>

....... ......

about 4 years ago · Juan Pablo Isaza Denunciar
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