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

179
Vistas
react native im trying to change the state of a button but its taking only the ternary else side

im trying to change the state using this but everyTime it takes add function only how to make the state change onPress ..what can i do please let me know

component //

        <Searchitems
          key={index}
          crypto={crypto}
          multipletest={multipletest}
          remove={crypto => remove(crypto)}
          add={crypto => add(crypto)}
          // status={status}
          removes="Remove"
          adds="Add"
           />




const [statusss, setStatus] = React.useState(false);   
onPress={() =>
          setStatus(!statusss) ?  props.remove(crypto)  :  props.add(crypto) 
        }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As mentioned in my comment, it is a bit difficult to understand what you are trying to do with your code. But still, try it like this. It appears that you are trying to check condition on a function.

const [statusss, setStatus] = React.useState(false);

useEffect(() => {
  statusss ? props.remove(crypto)  :  props.add(crypto)
}, [statusss]);

<SomeComponent
  onPress={() => setStatus(!statusss)}
/>
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