Open
Description
Hello,
I need to retrieve the context of a canvas, here is what I have tried:
import React, { Component } from 'react';
import Canvas from 'react-native-canvas';
import { View } from 'react-native';
class MyCanva extends Component {
handleCanvas = (canvas) => {
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'purple';
}
render() {
return (
<Canvas ref={this.handleCanvas}/>
)
}
}
export default function somefunction() {
let canvas = new MyCanva();
const context = canvas.getContext('2d');
return (
<View>
</View>
)
}
But it gives this error:
ERROR TypeError: canvas.getContext is not a function. (In 'canvas.getContext('2d')', 'canvas.getContext' is undefined)
Any idea where this comes from ?
Thanks
Metadata
Metadata
Assignees
Labels
No labels