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

115
Views
loop objects in array | React

I'm getting a list from the backend. There are 5 objects in my incoming list. I want to loop through only those whose "status" is "6". There is also a "continue" button. I will not show this button depending on the situation.

response

status 3 = invoice paid

status 6 = unpaid invoice

policyInstallmentDtoList: Array(5)
 0: {installmentNumber: 1, amount: 3032, currency: 'USD', status: '3', date: '09-06-2022'}
 1: {installmentNumber: 2, amount: 3032, currency: 'USD', status: '3', date: '09-07-2022'}
 2: {installmentNumber: 3, amount: 3032, currency: 'USD', status: '6', date: '09-08-2022'}
 3: {installmentNumber: 4, amount: 3032, currency: 'USD', status: '6', date: '09-09-2022'}
 4: {installmentNumber: 5, amount: 3032, currency: 'USD', status: '6', date: '09-10-2022'}

js

  const [hiddenControlButtonClass, setHiddenControlButtonClass] = useState('policypaymentinfo__button_container');

  useEffect(() => {
    if (paymentInfoData?.policyInstallmentDtoList?.map((payment) => payment.status)) {
      setHiddenControlButtonClass('hidden');
    } else {
      setHiddenControlButtonClass('policypaymentinfo__button_container');
    }
  }, [paymentInfoData]);

policyInfoData is the name of the incoming list.

I want to loop through the status 6 in the first if block.

html

<PaymentTable variant="edit" paymentList={paymentInfoData} value={value} collectionMethod={collectionMethod} />
<div className={hiddenControlButtonClass}>
  <AS.Button variant="outlined" onClick={handlePayment}>
    Contiune
  </AS.Button>
</div>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can do this:

useEffect(() => {
    paymentInfoData?.policyInstallmentDtoList?.forEach(item => {
       if(item.status == '6') {
           setHiddenControlButtonClass('hidden');
       } else {
           setHiddenControlButtonClass('policypaymentinfo__button_container');
       }
     })
  }, [paymentInfoData]);
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!