Could anyone tell me how to create refs in react dynamically?
For example, I have
<canvas style={{display:'none'}} ref={(el) => this.image = el} > </canvas>
I want to create more dynamically.
Like this:
<canvas style={{display:'none'}} ref={(el) => this.image1 = el} > </canvas>
<canvas style={{display:'none'}} ref={(el) => this.image2 = el} > </canvas>
<canvas style={{display:'none'}} ref={(el) => this.image3 = el} > </canvas>
So, can I do this, or is there another way to do it?
Basically I am getting the pdf url's from server which I am converting to canvas and then to image using it.
I have already done that for one image, but to do this dynamically I will have to create those refs dynamically too and thus be able to reference them.
So, how do I do that?
EDIT : Actually I have to create img tags too dynamically and create refs for those too as I want to create dataurl from canvas and display it in image tags.