I'm trying to load/draw a local image on canvas but it's not showing up.
render(state) {
const context = state.context;
const image=new Image();
image.onload=function(){
context.drawImage(image, this.position.x, this.poxition.y);
};
image.onerror=function(){alert("image load failed")};
image.src="./image.png"
}
and this is from the main component I'm importing the above into:
componentDidMount() {
const context = this.refs.canvas.getContext('2d');
this.setState({ context: context });
}