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

refactor: ConfigProvider form dependency inversion for v4 #43207

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

yoyo837
Copy link
Contributor

@yoyo837 yoyo837 commented Jun 27, 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

same as #42604 #43023
close #42499

💡 Background and solution

📝 Changelog

Language Changelog
🇺🇸 English Fix ConfigProvider makes Form component in the bundle even not use it.
🇨🇳 Chinese 修复使用 ConfigProvider 会导致未使用的 Form 组件也被打包的问题。

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

Refactored the form component and the config provider component to use a new ValidateMessagesContext to handle the validateMessages prop. This improves the code quality and the consistency of the validation messages. Created a new file validateMessagesContext.tsx to export the context.

🔍 Walkthrough

🤖 Generated by Copilot at 479bd28

  • Refactor the form components to use the new ValidateMessagesContext instead of the RcFormProvider to pass the validateMessages prop from the ConfigProvider component (link, link, link, link, link, link)
  • Create the validateMessagesContext.tsx file to export the ValidateMessagesContext as a React context (link)
  • Add the FormProvider component to wrap the FormContext.Provider component and pass the validateMessages prop to the form components (link, link)
  • Add parentheses around the parameters of arrow functions and render prop functions to follow the ESLint rule arrow-parens (link, link, link, link, link)

Sorry, something went wrong.

Unverified

The committer email address is not verified.
@yoyo837 yoyo837 changed the base branch from master to 4.x-stable June 27, 2023 02:59
@yoyo837 yoyo837 added 4.x In Ant Design 4.0 📦 Bundlesize labels Jun 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2023

@yoyo837 yoyo837 mentioned this pull request Jun 27, 2023
20 tasks

Unverified

The committer email address is not verified.
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
./dist/antd.min.js 281.88 KB (+4 B 🔺)
./dist/antd.min.css 66.31 KB
./dist/antd.dark.min.css 67.55 KB
./dist/antd.compact.min.css 66.26 KB
./dist/antd.variable.min.css 66.84 KB

@codecov
Copy link

codecov bot commented Jun 27, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (7cc23de) 100.00% compared to head (403e983) 100.00%.

Additional details and impacted files
@@             Coverage Diff              @@
##           4.x-stable    #43207   +/-   ##
============================================
  Coverage      100.00%   100.00%           
============================================
  Files             450       450           
  Lines            8346      8347    +1     
  Branches         2540      2540           
============================================
+ Hits             8346      8347    +1     
Impacted Files Coverage Δ
components/config-provider/index.tsx 100.00% <100.00%> (ø)
components/form/Form.tsx 100.00% <100.00%> (ø)

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

@zombieJ zombieJ merged commit 753510b into 4.x-stable Jun 27, 2023
@zombieJ zombieJ deleted the form-context-export-v4 branch June 27, 2023 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x In Ant Design 4.0 📦 Bundlesize
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConfigProvider组件会错误地导入整个'rc-field-form',导致包体积剧增
2 participants