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

Cant access refs inside <ArcherElement> component #180

Open
klmntv opened this issue Sep 2, 2022 · 2 comments
Open

Cant access refs inside <ArcherElement> component #180

klmntv opened this issue Sep 2, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@klmntv
Copy link

klmntv commented Sep 2, 2022

I am trying to use your library React-Archer and i really like it. It very helps me with my test task.

But i am faced with trouble: when i am trying to get access to div located inside with refForward i receive this:

(e4) {
e4 && ((0, l.assertContextExists)(f), f.registerChild(i2, e4));
}

how can i get access to that div? You can watch my code here:

https://github.com/klmntv/df_designer_frontend_test

@pierpo
Copy link
Owner

pierpo commented Sep 7, 2022

Hi!

Yes indeed, because this line overrides the given ref...

return React.cloneElement(child, { ...child.props, ref: onRefUpdate });

I need to find a better solution!

Thank you for the issue!

@pierpo pierpo added the bug Something isn't working label Sep 14, 2022
@pierpo
Copy link
Owner

pierpo commented Sep 30, 2022

By the way, I did not provide a workaround.

I guess you could add an additional element in between.

<ArcherElement>
  <div> {/* <- add this, with proper styling of course */}
    <YourElement ref={ref} />
  </div>
</ArcherElement>

I hope it helps 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants