Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!