ant-design / ant-design

An enterprise-class UI design language and React UI library
https://ant.design
MIT License
91.91k stars 48.93k forks source link

remix项目中使用antd 划词翻译插件,导致渲染报错 #50657

Closed hemengke1997 closed 2 weeks ago

hemengke1997 commented 2 weeks ago

Reproduction link

https://github.com/hemengke1997/antd-remix-reproduction

Steps to reproduce

pnpm i

pnpm dev

What is expected?

页面正常展示

What is actually happening?

页面报错

Environment Info
antd 5.20.3
React 18.2
System Macos14
Browser chrome latest

安装划词翻译,但没有使用antd的情况,只是报hydrate不匹配,但是不会影响页面渲染 使用了antd后,页面报错不能正常展示了

Wxh16144 commented 2 weeks ago

我发现我也安装了 划词翻译 插件(但是不知道为什么被我禁用了,应该也是水合导致 antd 文档报错🤔)

不过你反馈这个问题太边缘了,不应该是组件库来修复问题。

hemengke1997 commented 2 weeks ago

水合出问题并不会导致页面无法渲染,本质是 antd css 的 findStyle 方法出错了

hemengke1997 commented 2 weeks ago

临时解决了,在hydrate之前把chrome插件注入的元素都删了。

function removeThirdPartyDOM() {
  let sibling = document.body.nextElementSibling
  while (sibling) {
    const nextSibling = sibling.nextElementSibling
    sibling.remove()
    sibling = nextSibling
  }
}

removeThirdPartyDOM()

hydrate()