Skip to content

Instantly share code, notes, and snippets.

@kensmash
Created February 18, 2019 15:51
Show Gist options
  • Save kensmash/6ec6cc32deed1cf24dfea4c886eb94c3 to your computer and use it in GitHub Desktop.
Save kensmash/6ec6cc32deed1cf24dfea4c886eb94c3 to your computer and use it in GitHub Desktop.
React Native Canvas test code
import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Canvas from "react-native-canvas";
export default class App extends React.Component {
handleCanvas = canvas => {
const ctx = canvas.getContext("2d");
ctx.fillStyle = "purple";
ctx.fillRect(0, 0, 100, 100);
};
render() {
return (
<View style={styles.container}>
<Canvas ref={this.handleCanvas} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment