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

fix: table warning message when columns=[] #966

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

Francoshum95
Copy link
Contributor

@Francoshum95 Francoshum95 commented Mar 13, 2023

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

fix ant-design/ant-design#41150

💡 Background and solution

Issue: Error message logged on the console when columns is empty []. This issue occurs in the custom body component:

<Table
 {...props}
 components={{
          body: renderSomethinig,
        }}
/>

After looking into it, I find that there's no major issue when columns is empty []. So, I just added a conditional check to only log an error if columns.length > 0.

📝 Changelog

Language Changelog
🇺🇸 English fix error message being logged in the custom body component when columns is empty []
🇨🇳 Chinese 修复自定义 body component, columns[] 為空時 错误报错错误报

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@vercel
Copy link

vercel bot commented Mar 13, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
table ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 13, 2023 at 1:05PM (UTC)

@codecov
Copy link

codecov bot commented Mar 17, 2023

Codecov Report

Merging #966 (b48756a) into master (3d731c4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head b48756a differs from pull request most recent head 659bc01. Consider uploading reports for the commit 659bc01 to get more accurate results

@@           Coverage Diff           @@
##           master     #966   +/-   ##
=======================================
  Coverage   99.49%   99.49%           
=======================================
  Files          36       36           
  Lines         988      989    +1     
  Branches      319      305   -14     
=======================================
+ Hits          983      984    +1     
  Misses          5        5           
Impacted Files Coverage Δ
src/Table.tsx 99.06% <100.00%> (+<0.01%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@zombieJ zombieJ merged commit ae3bc5b into react-component:master Mar 17, 2023
);

if (props.columns.length > 0) {
warning(
Copy link
Member

@yoyo837 yoyo837 Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥不把if的条件放warning的判断参数上?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我来改一下

@@ -701,6 +701,24 @@ describe('Table.Basic', () => {
});
});

it('without warning - columns is emplty', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我顺带改一下吧

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#972 被大佬抢了

@Francoshum95 Francoshum95 deleted the fix/41150-fix-warning branch March 18, 2023 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table 使用了自定义 component.body 。当 columns={[]} 控制台就会报错
5 participants