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

[BUG]Ref can not attach because multiple copies of Rax are used. #1904

Open
yinhangfeng opened this issue Jun 2, 2020 · 5 comments
Open
Labels

Comments

@yinhangfeng
Copy link

yinhangfeng commented Jun 2, 2020

给 render 组件设置 ref 无效,会错误的提示有多个 rax 版本,但其实只有一个
ref 必须在组件内部使用么?

To Reproduce

render(
  <div>
    <div ref={() => {}}></div>
  </div>,
  document.getElementById('root'),
  { driver: UniversalDriver }
);
  • Device: Mac
  • OS: Mac
  • Browser chrome
  • Rax Version 1.1.3
@yinhangfeng yinhangfeng added the Bug label Jun 2, 2020
@SoloJiang
Copy link
Collaborator

Please check your local dependencies. Try rm -rf node_modules npm install.

@yinhangfeng
Copy link
Author

Please check your local dependencies. Try rm -rf node_modules npm install.

不是多个 rax 版本造成的,是给 render 的顶层组件设置 ref 时会提示这个警告,如果在组件内部就不会有问题

@SoloJiang
Copy link
Collaborator

根据提供的代码已复现

@SoloJiang SoloJiang reopened this Jun 29, 2020
@7213
Copy link
Contributor

7213 commented Sep 29, 2020

根据提供的代码已复现

我也遇到过相同问题,排查是因为顶层组件在其渲染上下文中没有对应的ownerComponent导致,react确实可以在顶层组件设置ref
image

@xmsz
Copy link

xmsz commented Feb 8, 2021

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants