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

93
Views
¿Botón dentro de una pestaña para cambiar de pestaña usando Ant Design en React?

Buscando poner un botón dentro del cuerpo de una pestaña que simplemente cambiaría a la siguiente pestaña y viceversa. He estado jugando con esto durante unas horas y no puedo encontrar la manera de hacerlo. Cualquier ayuda es apreciada

 import { Tabs } from 'antd'; const { TabPane } = Tabs; function callback(key) { console.log(key); } const Demo = () => ( <Tabs defaultActiveKey="1" onChange={callback}> <TabPane tab="Tab 1" key="1"> Content of Tab Pane 1 <button type="button"> Go to tab 2 </button> </TabPane> <TabPane tab="Tab 2" key="2"> Content of Tab Pane 2 </TabPane> <TabPane tab="Tab 3" key="3"> Content of Tab Pane 3 </TabPane> </Tabs> ); ReactDOM.render(<Demo />, mountNode);

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

0

Debe usar la propiedad activeKey y almacenar la clave activa en el estado.

 import React from 'react' import { Tabs } from 'antd'; const { TabPane } = Tabs; function Demo () { const [activeKey, setActiveKey] = React.useState('1') const onKeyChange = (key) => setActiveKey(key) return ( <Tabs defaultActiveKey="1" activeKey={activeKey} onChange={onKeyChange}> <TabPane tab="Tab 1" key="1"> Content of Tab Pane 1 <button onClick={() => onKeyChange('2')}>Go to "Tab 2"</button> </TabPane> <TabPane tab="Tab 2" key="2"> Content of Tab Pane 2 <button onClick={() => onKeyChange('1')}>Go to "Tab 1"</button> </TabPane> <TabPane tab="Tab 3" key="3"> Content of Tab Pane 3 </TabPane> </Tabs> ) } ReactDOM.render(<Demo />, document.getElementById('root'));

No me he probado a mí mismo, pero debería darte una idea de cómo hacerlo.

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!