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

141
Vistas
how to update items object after on onTextChange in searchable dropdown in react native?

I am using react-native-searchable-dropdown for my react native project.

When onTextChange is fired I make a call to my backend with the text the user inputs. Then I set the data I get back (array of objects) in the state:

async inputBrandText (text) {
      const brands = await SearchForBrands(params);
      this.setState((state) => {
          return state.brands = brands
      })
};

In the items element I reference this state array:

<SearchableDropdown
    textInputProps={
        {
            placeholder: "",
            underlineColorAndroid: "transparent",
            style: {
               ...
            },
            onTextChange: text => this.inputBrandText(text)
        }
    }
    items={this.state.brands}
/>

But the items get refreshed one key stroke after it should actually be refreshed. So I think when the onTextChange event is fired, the items object or array is read in. Then I change the this.state.brands object with the data from the backend. But then no update occurs and the items object is not updated. Therefor the old items object is shown.

How can I solve this problem in a class based component?

Thanks!

PS: This is my ComponendDidMount:

async componentDidMount () {
  const brands = await SearchForBrands(params);
  this.setState((state) => {
      return state.showBrandSuggestions = brands
  })
}

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this way

Your componentDidMount method should be like

async componentDidMount () {
  const brands = await SearchForBrands(params);
  this.setState({ showBrandSuggestions: brands });
}

Your inputBrandText method should be like

async inputBrandText (text) {
  const brands = await SearchForBrands(params);
  this.setState({ brands: brands });
};
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