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: legacy context with function and class nesting cause RHL patch failed #431

Open
wants to merge 1 commit into
base: 6.x
Choose a base branch
from

Conversation

jas0ncn
Copy link

@jas0ncn jas0ncn commented Mar 12, 2020

该 PR 为了修复 Ant Design 3.x issue #22136

Table 表格使用了已经废弃的 Context 处理方式,因为 classfunction 的嵌套,导致 React Hot Loader patch 更新的时候失败。从 RHL 的 issue 中找到了点蛛丝马迹,由此处理了这个问题。

此 PR 将所有的 stateless function component 改为了 pure class component 的形式。

注意:这本不是 rc-table 的问题,但是 RHL 似乎停止了对 Legacy Context 的支持,只能设置为忽略热更新,所以由 rc-table 修复问题。

@vercel
Copy link

vercel bot commented Mar 12, 2020

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://zeit.co/react-component/table/iw7ylflyc
✅ Preview: https://table-git-fork-jas0ncn-6x.react-component.now.sh

@codecov
Copy link

codecov bot commented Mar 12, 2020

Codecov Report

Merging #431 into 6.x will not change coverage.
The diff coverage is 91.56%.

Impacted file tree graph

@@           Coverage Diff           @@
##              6.x     #431   +/-   ##
=======================================
  Coverage   89.49%   89.49%           
=======================================
  Files          16       16           
  Lines         838      838           
  Branches      245      245           
=======================================
  Hits          750      750           
  Misses         88       88
Impacted Files Coverage Δ
src/TableHeader.tsx 97.05% <100%> (ø) ⬆️
src/ColGroup.tsx 100% <100%> (ø) ⬆️
src/HeadTable.tsx 76.19% <76.19%> (ø) ⬆️
src/BodyTable.tsx 94.11% <93.93%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7d53b6...dbae0ed. Read the comment docs.

@yoyo837
Copy link
Member

yoyo837 commented Mar 13, 2020

这里修改的Context处理方式是同一版本发布的同一套API 分别在函数式组件和class组件的两种形式吧?

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

@yoyo837 是的,但是当 class 和 function 嵌套的时候,会导致 RHL 的问题,可以看这个 issue:ant-design/ant-design#22136

@afc163
Copy link
Member

afc163 commented Mar 13, 2020

antd 3.x 还需要对 React 15 进行支持,请检查相关用法。

@yoyo837
Copy link
Member

yoyo837 commented Mar 13, 2020

@yoyo837 是的,但是当 class 和 function 嵌套的时候,会导致 RHL 的问题,可以看这个 issue:ant-design/ant-design#22136

所以不存在更换已废弃的API这回事。

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

@yoyo837 嗯,没有更换,只是换成 class 的写法

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

antd 3.x 还需要对 React 15 进行支持,请检查相关用法。

好的,我 check 一下,主要是替换掉 PureComponent,有相关测试用例么?

@afc163
Copy link
Member

afc163 commented Mar 13, 2020

antd 3.x-stable 分支上有,rc-table 里没加。

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

antd 3.x-stable 分支上有,rc-table 里没加。

OK,我 link 到 antd 那边跑一下

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

@afc163 我跑了一下 antd 3.x-stable 分支的测试,没跑通,没改动的组件的 snapshot 都对不上,迷惑...

我看了一下 React15 的源码,PureComponent 是有的,这个 PR 的改动是将 function 改成了 class,内部逻辑没有修改。

https://github.com/facebook/react/blob/571a9208d5133e8737f565fe60b762d201f0d37c/src/isomorphic/React.js#L81

@jas0ncn
Copy link
Author

jas0ncn commented Mar 13, 2020

@afc163 我跑了一下 antd 3.x-stable 分支的测试,没跑通,没改动的组件的 snapshot 都对不上,迷惑...

我看了一下 React15 的源码,PureComponent 是有的,这个 PR 的改动是将 function 改成了 class,内部逻辑没有修改。

看了一下 antd 仓库用的 Github Actions 好像没有测试 React15?

@afc163
Copy link
Member

afc163 commented Mar 13, 2020

3.x-stable 分支。

@yoyo837
Copy link
Member

yoyo837 commented Mar 16, 2020

should have correct className when use12Hours is true 这个在3.x-stable 本身没通过。

@jas0ncn
Copy link
Author

jas0ncn commented Mar 17, 2020

should have correct className when use12Hours is true 这个在3.x-stable 本身没通过。

@yoyo837 我试了一下,我这里的测试用例生成的 style 全都没带分号,令人迷惑... 你这里会么

image

@afc163
Copy link
Member

afc163 commented Mar 26, 2020

可以再测测,3.x-stable 自身的问题修复过了。

@afc163
Copy link
Member

afc163 commented Aug 29, 2020

@jas0ncn ping~

@jas0ncn
Copy link
Author

jas0ncn commented Aug 31, 2020

@jas0ncn ping~

pong 😅 之前有点忙,这两天我抽空看看~

@yoyo837
Copy link
Member

yoyo837 commented Mar 27, 2021

ping

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.

None yet

3 participants