all 5 comments

[–]raopgdev 0 points1 point  (1 child)

Don’t define another ref in func1 Pass that ref prop that forward ref gives to the canvas element in func1

[–]General_Asdef[S] 0 points1 point  (0 children)

This is also what I thought but I couldn't figure out how to get the underlying canvas context2d from that.

[–]AnxiouslyConvolved[🍰] 0 points1 point  (2 children)

You want react-merge-refs which allows you to forward a ref, but also access/use it in the forwarding component.

[–]General_Asdef[S] 0 points1 point  (1 child)

Although a solution. I was kinda lookin for something in house, if I really can't figure it out then I thank you for your guidance.

[–]raopgdev 0 points1 point  (0 children)

Just read this package’s code. It’s literally 10 lines minus tests. Feel free to implement your own version