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

feat: support react18 #5046

Merged
merged 11 commits into from May 10, 2022
Merged

feat: support react18 #5046

merged 11 commits into from May 10, 2022

Conversation

miracles1919
Copy link
Contributor

@miracles1919 miracles1919 commented Apr 8, 2022

  • 新增 render 方法,支持 legacy 和 concurrent 模式,移植自 rc-util
  • 更新 react、react-dom 版本
  • 更新 testing-library 版本
  • 修复 failed test

发了个 npm 包用来测试 antd-mobile-with-react18

@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

package.json Outdated
@@ -48,7 +48,8 @@
"@types/jest": "^27.4.1",
"@types/jest-axe": "3.5.3",
"@types/lodash": "^4.14.180",
"@types/react": "^17.0.43",
"@types/react": "^17.0.44",
Copy link
Member

Choose a reason for hiding this comment

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

诶这里的 @types/react 咋还是 17

Copy link
Contributor Author

Choose a reason for hiding this comment

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

前几天我更新的时候还是 17,这两天才更新的 18..  😮

@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

src/utils/compatible.ts Outdated Show resolved Hide resolved
Copy link
Member

@awmleer awmleer left a comment

Choose a reason for hiding this comment

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

LGTM

等 antd 先发布吧~它们发完没问题了我再来合并
顺便我也还得抽空再看看 React 18 strict mode 下的适配问题

@awmleer awmleer linked an issue Apr 9, 2022 that may be closed by this pull request
@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

Copy link
Member

@awmleer awmleer left a comment

Choose a reason for hiding this comment

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

emm…… CI 挂了,看起来还有些组件漏加了 children 定义

@miracles1919
Copy link
Contributor Author

其他的我晚点在看看 ~

@awmleer
Copy link
Member

awmleer commented Apr 9, 2022

嗯嗯不急~反正还要等 antd

@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented Apr 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@codecov
Copy link

codecov bot commented Apr 10, 2022

Codecov Report

Merging #5046 (1fa57ee) into master (c1cfdde) will increase coverage by 0.14%.
The diff coverage is 73.68%.

❗ Current head 1fa57ee differs from pull request most recent head 5a6eb2d. Consider uploading reports for the commit 5a6eb2d to get more accurate results

@@            Coverage Diff             @@
##           master    #5046      +/-   ##
==========================================
+ Coverage   54.46%   54.60%   +0.14%     
==========================================
  Files         278      279       +1     
  Lines        5795     5857      +62     
  Branches     1349     1392      +43     
==========================================
+ Hits         3156     3198      +42     
- Misses       2476     2497      +21     
+ Partials      163      162       -1     
Impacted Files Coverage Δ
src/components/floating-bubble/floating-bubble.tsx 0.00% <ø> (ø)
src/components/pull-to-refresh/pull-to-refresh.tsx 0.00% <0.00%> (ø)
src/components/toast/methods.tsx 0.00% <0.00%> (ø)
src/utils/render.ts 79.31% <79.31%> (ø)
src/components/floating-panel/floating-panel.tsx 97.01% <100.00%> (ø)
src/components/picker-view/wheel.tsx 88.88% <100.00%> (ø)
src/utils/render-to-body.ts 100.00% <100.00%> (ø)
src/components/picker/picker.tsx 72.13% <0.00%> (-4.96%) ⬇️
src/components/cascader-view/cascader-view.tsx 93.22% <0.00%> (-1.61%) ⬇️
src/components/collapse/collapse.tsx 87.64% <0.00%> (-0.87%) ⬇️
... and 19 more

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 c1cfdde...5a6eb2d. Read the comment docs.

@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@miracles1919 miracles1919 force-pushed the feat/react18 branch 3 times, most recently from d714ce8 to 5918a41 Compare April 14, 2022 10:02
@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

1 similar comment
@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@awmleer
Copy link
Member

awmleer commented May 7, 2022

话说这个 PR 是不是可以再搞一下了 🤔 antd 已经发布了兼容 React 18 的逻辑

@miracles1919
Copy link
Contributor Author

ok 下午搞下

@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@miracles1919 miracles1919 force-pushed the feat/react18 branch 2 times, most recently from 7e461e3 to c88b689 Compare May 9, 2022 07:57
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

1 similar comment
@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

Comment on lines 88 to 89
// eslint-disable-next-line
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

这个好像不用加 ignore,我删掉之后好像也没有报错

@@ -155,7 +155,7 @@ export const PullToRefresh: FC<PullToRefreshProps> = p => {
axis: 'y',
target: elementRef,
enabled: !props.disabled,
eventOptions: supportsPassive ? { passive: false } : false,
eventOptions: supportsPassive ? { passive: false } : undefined,
Copy link
Member

Choose a reason for hiding this comment

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

这里也是,我这里不改也是正常的

@@ -31,7 +31,7 @@ exports[`ActionSheet basic usage 1`] = `
</div>
<div
class="adm-popup-body adm-popup-body-position-bottom"
style="transform: translate(0, 92.19667326069148%);"
style="transform: translate(0, 68.58969969000708%);"
Copy link
Member

Choose a reason for hiding this comment

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

这里倒是会 test 的时候报错,看起来好像每次运行的值都不一样:

image

@miracles1919
Copy link
Contributor Author

miracles1919 commented May 9, 2022

之前更新 yarn.lock 的时候,@use-gesture/react 更了一个小版本 10.2.10 -> 10.2.11,重新 install 的话,会有一些 ts 类型错误

  1. eventOptions 我看定义是 eventOptions?: AddEventListenerOptions
  2. useDrag bounds 那里用 ref 也会有类型错误,我就先加了个 ts-ignore

@github-actions
Copy link
Contributor

github-actions bot commented May 9, 2022

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@awmleer
Copy link
Member

awmleer commented May 10, 2022

eventOptions 应该是 ts 的 dom 类型定义更新导致的,不过 passive 保险起见还是得兼容一下这种情况:

image

我改成这样了,还稍微温和一些:

eventOptions: supportsPassive
  ? { passive: false }
  : (false as unknown as AddEventListenerOptions),

@awmleer
Copy link
Member

awmleer commented May 10, 2022

floating bubble 的 bounds 我也改成单行里写 any 了,比 ts-ignore 还稍微好一些,感觉这里应该是 use-gesture 的问题,我查了它文档,useDrag 的 bounds 是支持 ref 的:

Drag bounds
Since v10 and for the drag gesture only, bounds can be a React ref or an HTMLElement, in which case the dragged element will be constrained to the element bounds (calculated with getBoundingClientRect).

Copy link
Member

@awmleer awmleer left a comment

Choose a reason for hiding this comment

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

LGTM 总算可以合并了 🎉

@awmleer awmleer merged commit b1dc786 into ant-design:master May 10, 2022
@github-actions
Copy link
Contributor

PR preview has been successfully built and deployed to https://antd-mobile-preview-pr-5046.surge.sh

@lbyupup
Copy link

lbyupup commented May 12, 2022

LGTM 总算可以合并了 🎉
大佬,请问组件还是会报children属性没有,这个得把antd升级到哪个版本可以解决

@awmleer
Copy link
Member

awmleer commented May 12, 2022

@lbyupup 看下发布日志哈,里面有写,不确定的话,直接升级到最新版也可以

@miracles1919 miracles1919 deleted the feat/react18 branch May 20, 2022 03:37
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.

支持 React 18
3 participants