Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
Toggle a spinner on button click inside an antd table row

I have a table like this with a column that contains a button like this:

const columns = [
...
  {
    title: "button",
    dataIndex: "key",
    render: (text, record) => {
      return (
        <Button
          icon={<DeleteOutlined />}
          onClick={() => pendingToggle()}
        ></Button>
      );
    }
  }
];

When you click on this button it should swap the button with <Spin /> from ant design only on that row it is clicked. I have written a piece of code but it doesn't work you can find it here !

How can I do it?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to use React states so that the DOM gets re-rendered. To do so, you need a react component, something like:

function ButtonCell() {
  const [pending, setPending] = useState(false);

  return pending ? (
    <Spin />
  ) : (
    <Button icon={<DeleteOutlined />} onClick={() => setPending(true)}>
      Delete
    </Button>
  );
}

In your table you can type:

{
  title: "button",
  dataIndex: "key",
  render: () => {
    return <ButtonCell />;
  } // or just `render: ButtonCell`
}

Working example:

Edit ant.design (forked)

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda