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: Progress throws warning findDOMNode is deprecated in StrictMode #42241

Merged
merged 2 commits into from
May 10, 2023

Conversation

BoyYangzai
Copy link
Contributor

@BoyYangzai BoyYangzai commented May 9, 2023

[中文版模板 / Chinese template]

🤔 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

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Fix Progress throws warning findDOMNode is deprecated in StrictMode
🇨🇳 Chinese 修复Progress抛出的警告 "findDOMNode is deprecated in StrictMode"

☑️ 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

🚀 Summary

🤖 Generated by Copilot at 33029d7

Added ref forwarding and a new test case for the Progress component. This improves the component's compatibility with React strict mode and other components that use refs, such as Tooltip.

🔍 Walkthrough

🤖 Generated by Copilot at 33029d7

  • Wrap Progress component in React.forwardRef and pass ref prop to div element to support ref forwarding (link,link,link,link)
  • Import Tooltip component from antd and add test case for Progress component wrapped in Tooltip component to check for no strict mode warning (link,link)
  • Move ProgressTypes type from progress.tsx to index.test.tsx to avoid circular dependency issue (link,link)

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2023

@codecov
Copy link

codecov bot commented May 9, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (1a44c46) 100.00% compared to head (3a1be82) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #42241   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          618       618           
  Lines        10539     10539           
  Branches      2879      2879           
=========================================
  Hits         10539     10539           
Impacted Files Coverage Δ
components/progress/progress.tsx 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

);
expect(errSpy).not.toHaveBeenCalledWith(
'Warning: findDOMNode is deprecated in StrictMode. findDOMNode was passed an instance of DomWrapper which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node',
);
Copy link
Member

Choose a reason for hiding this comment

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

这个 warning 过于完整了,如果 react 改个字符就对不上了。

Copy link
Member

Choose a reason for hiding this comment

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

.not.toHaveBeenCalledWith(expect.stringContaining('findDOMNode is deprecated in StrictMode'))

@afc163 afc163 merged commit 7de7a8b into ant-design:master May 10, 2023
52 checks passed
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.

搭配试用Progress和Tooltip组件,控制台报错:findDOMNode is deprecated in StrictMode.
3 participants