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

217
Views
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 answers
Answer question

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 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!