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

260
Views
Conditional Operator for React Components, not updating

I currently have 2 Components that work conditionally, but i would like it to update and change when the createdSavingsGoal state array is greater than 0 (i.e Not empty)

Then it shows a List.. When its empty it shows a Form that allows me to Post to that array. Currently i have to refresh that page but i would just like it to work. automatically

Im not brilliant with State so if im doing something obvious.

this.state = {
  createdSavingsGoal: "",
};

..

render() {
const { createdSavingsGoal } = this.state;
if (createdSavingsGoal.length > 0) {
  return <ViewSavingsGoal />;
} else {
  return <CreateSavingsGoal />;
}
about 4 years ago · Juan Pablo Isaza
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!