pierpo / react-archer

🏹 Draw arrows between React elements 🖋
https://pierpo.github.io/react-archer/
MIT License
1.17k stars 68 forks source link

Cant access refs inside <ArcherElement> component #180

Open klmntv opened 2 years ago

klmntv commented 2 years ago

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 commented 2 years ago

Hi!

Yes indeed, because this line overrides the given ref... https://github.com/pierpo/react-archer/blob/d82b85715288b895e51dd2fe00dccd027b3dc359/src/ArcherElement/ArcherElement.tsx#L78

I need to find a better solution!

Thank you for the issue!

pierpo commented 2 years ago

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 :blush: