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

178
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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