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

304
Views
Al cerrar una pestaña en particular, cierra todas las pestañas

Mire esto, al cerrar una pestaña en particular, cierra todas las pestañas que están abiertas. Solo quiero que se cierre esa pestaña en particular.

 remove = targetKey => { let { activeKey } = this.state; let lastIndex; this.setState(prevState => { const newState = {...prevState}; newState.forEach((pane, i) => { if (pane.key === targetKey) { lastIndex = i - 1; } }); const panes = newState.filter(pane => pane.key !== targetKey); if (panes.length && activeKey === targetKey) { if (lastIndex >= 0) { activeKey = panes[lastIndex].key; } else { activeKey = panes[0].key; } } return ({panes, activeKey}); }); };

Consulte este enlace https://jsfiddle.net/yjumr4ox/1/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

El problema es que está iterando sobre todo el estado en newState.forEach y newState.filter . Debe iterar sobre los paneles en el estado. como esto:

 remove = targetKey => { let { activeKey } = this.state; let lastIndex; this.setState(prevState => { const newState = {...prevState}; newState.panes.forEach((pane, i) => { if (pane.key === targetKey) { lastIndex = i - 1; } }); const panes = newState.panes.filter(pane => pane.key !== targetKey); if (panes.length && activeKey === targetKey) { if (lastIndex >= 0) { activeKey = panes[lastIndex].key; } else { activeKey = panes[0].key; } } return ({panes, activeKey}); }); };
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!