Expanded Row 在 React 和 AntDesgin 中不会 Collapse

Expanded Row is not Collapse in React and AntDesgin

我正在使用 Ant Design table,其中我正在使用行扩展功能。我的查询是当我单击 table 中的任何一行时,该行正在打开但不会向后折叠。我只是想要这样,如果我点击“+”图标,该行应该打开,如果点击“_”图标,该行应该折叠,如果前一行在点击下一行时打开,则前一行也应该折叠。 ...请提供我给出的 link 的任何解决方案,其中我已经实现了一半的代码。将不胜感激....提前致谢。

enter code here

实例:https://codesandbox.io/s/eloquent-http-jxf1m?file=/src/App.js

你可以检查上一个和下一个是否相同,这意味着崩溃。 否则展开。

Working link

const onExpand = (_, key) => {

  setExpandedKey((prev) => {
    const newKey = key.key;
    if (prev !== newKey) {
      return newKey;
    }
    return null;
  });
};