Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProTable onDataSourceChange wrong typescript 🐛[BUG] #7353

Closed
matteomaiocchi99 opened this issue Jul 11, 2023 · 2 comments
Closed

ProTable onDataSourceChange wrong typescript 🐛[BUG] #7353

matteomaiocchi99 opened this issue Jul 11, 2023 · 2 comments

Comments

@matteomaiocchi99
Copy link

Good morning, I noticed that there is an error in the typing of the onDataSourceChange prop of the ProTable component: according to the code typing (and also the documentation), the function should receive only one prop, namely dataSource, but in reality, two different dataSource are being passed.
Thank you for your support.

ant-design/pro-components => version 2.6.2

@chenshuai2144
Copy link
Contributor

TAutomatically replying with ChatGPT can be attempted, but it cannot be guaranteed to be completely accurate and may not fully address all issues. Please feel free to reply if you have any further questions or concerns.
此回复基于 ChatGPT 自动生成,可以尝试下方案,官方人员会在一定时间后继续继续处理。

Hi there,

Thank you for reaching out to us about the issue with the onDataSourceChange prop in ProTable component. I apologize for the inconvenience caused.

Looking at the code and documentation, it seems that there is a discrepancy with the typing. I understand that you are encountering a situation where two different dataSource objects are being passed instead of just one.

To resolve this issue, you can try the following steps:

  1. Verify that you are using the correct version of ant-design/pro-components. As of now, version 2.6.2 is the latest.

  2. If you are using TypeScript, you can manually type the onDataSourceChange prop to accept two arguments, as shown below:

import { ProColumns, ProTableProps } from 'ant-design/pro-table';

interface YourDataItemType {
  // Define your data item type here
}

const columns: ProColumns<YourDataItemType>[] = [...];

const YourComponent: React.FC = () => {
  const handleDataSourceChange = (newDataSource: YourDataItemType[], action: 'add' | 'update' | 'delete') => {
    // Handle the dataSource change here based on the action
  };

  return (
    <ProTable<YourDataItemType>
      columns={columns}
      onDataSourceChange={handleDataSourceChange}
      // other props
    />
  );
};

By manually typing the prop, you can now handle the newDataSource and action separately in the handleDataSourceChange callback function.

  1. If you find that even after the above steps, the issue persists, I would recommend opening an issue on the official GitHub repository of ant-design/pro-components. This will allow the maintainers to further investigate the problem and provide a more permanent solution.

I hope this helps! Let me know if you have any further questions.

@github-actions
Copy link

Hello @matteomaiocchi99. Please provide a online reproduction by forking this link https://codesandbox.io/ or a minimal GitHub repository.

你好 @matteomaiocchi99, 我们需要你提供一个在线的重现实例以便于我们帮你排查问题。你可以通过点击 此处 创建一个 codesandbox 或者提供一个最小化的 GitHub 仓库。
如何写个好问题?https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants