Created
February 18, 2019 15:51
-
-
Save kensmash/6ec6cc32deed1cf24dfea4c886eb94c3 to your computer and use it in GitHub Desktop.
React Native Canvas test code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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