I made a color picker with React and Canvas. Currently the components are rendered in React and canvas is done with vanilla javascript. I\'d like to two to mesh more, so I w
You can add a ref
function attribute on the canvas
element:
Then you’ll have access to the context through this.context
:
colorStripClick: function() {
var imageData = this.context.getImageData(x, y, 1, 1).data
}
You can also use the event object to access to DOM node as already pointed out, but this way you’ll have access from anywhere, not just event handlers.