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

92
Views
Agregue una nueva columna al hacer clic en el botón en la tabla de reacción de React JS

Necesito agregar una nueva columna a la tabla de reacción al hacer clic en el botón, incluso después de volver a representar la tabla con la bandera. No puedo agregar una nueva columna. ¿Puede sugerirme dónde me equivoqué? Aquí está el código sandbox ejecutable.

https://codesandbox.io/s/tannerlinsley-react-table-row-selection-forked-3gcwm?file=/src/App.js

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Debe mantener un estado para las columnas y cambiarlo en consecuencia utilizando el método setter. Prueba como a continuación:

 const intialColumns = [ { Header: "Units", accessor: "units", width: 400 }, { Header: "Units1", accessor: "units1", width: 400 } ]; function App() { const [columns, setColumns] = useState(intialColumns); const addColumn = () => { setColumns((prevCols) => [ ...prevCols, { Header: "Units3", accessor: "units3", width: 400 } ]); }; const data = React.useMemo(() => makeData(100), []); return ( <Styles> <button style={{ margin: "5px" }} onClick={addColumn}> click here to add column{" "} </button> <Table columns={columns} data={data} /> </Styles> ); }

Códigosycaja:

Editar tannerlinsley/react-table: selección de filas (bifurcado)

about 4 years ago · Santiago Trujillo 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!