Вот код ( live codesandbox ):
import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { Table, Tooltip } from "antd";
const columns = [
{
title: <Tooltip title="Address">A</Tooltip>,
dataIndex: "address",
sorter: (a, b) => a.address.length - b.address.length,
render: cell => <Tooltip title={cell}>{cell[0]}</Tooltip>
}
];
const data = [
{
key: "1",
address: "New York No. 1 Lake Park"
},
{
key: "2",
address: "London No. 1 Lake Park"
},
{
key: "3",
address: "Sidney No. 1 Lake Park"
},
{
key: "4",
address: "London No. 2 Lake Park"
}
];
ReactDOM.render(
<Table columns={columns} dataSource={data} />,
document.getElementById("container")
);
При наведении курсора на заголовок таблицы вместо обычного antd Tooltip
отображается простая подсказка:
Однако после отключения sorter
подсказка отображается корректно:
Какзаставить Tooltip
и sorter
работать вместе?