mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #46542 [@types/react-native-canvas] Fix Canvas#toDataURL type definition. by @gin0606
https://github.com/iddan/react-native-canvas#canvastodataurl
This commit is contained in:
parent
be5c4773c1
commit
4eb18eb7f4
2
types/react-native-canvas/index.d.ts
vendored
2
types/react-native-canvas/index.d.ts
vendored
@ -131,7 +131,7 @@ export interface CanvasRenderingContext2D {
|
||||
export default class Canvas extends React.Component<CanvasProps> {
|
||||
width: number;
|
||||
height: number;
|
||||
toDataURL: () => string;
|
||||
toDataURL: () => Promise<string>;
|
||||
getContext: (context: string) => CanvasRenderingContext2D;
|
||||
}
|
||||
|
||||
|
||||
@ -130,6 +130,20 @@ class CanvasTest extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleToDataURL(canvas: Canvas) {
|
||||
canvas.width = 100;
|
||||
canvas.height = 100;
|
||||
|
||||
const context = canvas.getContext('2d');
|
||||
|
||||
context.fillStyle = 'purple';
|
||||
context.fillRect(0, 0, 100, 100);
|
||||
|
||||
canvas.toDataURL().then((dataURL: string) => {
|
||||
void dataURL;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<View>
|
||||
@ -156,6 +170,9 @@ class CanvasTest extends React.Component {
|
||||
<Example sample={require('./images/embed-html.png')}>
|
||||
<Canvas ref={this.handleEmbedHTML} />
|
||||
</Example>
|
||||
<Example sample={require('./images/to-data-url.png')}>
|
||||
<Canvas ref={this.handleToDataURL} />
|
||||
</Example>
|
||||
</ScrollView>
|
||||
</View>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user