Skip to content

Instantly share code, notes, and snippets.

@doomsower
Created August 10, 2016 13:11
Show Gist options
  • Save doomsower/2784415a25d7278526321edb66f05676 to your computer and use it in GitHub Desktop.
Save doomsower/2784415a25d7278526321edb66f05676 to your computer and use it in GitHub Desktop.
VSCode rn snippets
{
/*
// Place your snippets for JavaScript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
"React native component": {
"prefix": "rnc",
"body": [
"import React, {Component, PropTypes} from 'react';",
"import {View, StyleSheet} from 'react-native';",
"",
"export default class ${1:ComponentName} extends Component {",
"",
"\tstatic propTypes = {",
"\t};",
"",
"\trender() {",
"\t\treturn (",
"\t\t\t<View style={styles.container}>",
"\t\t\t</View>",
"\t\t);",
"\t}",
"}",
"",
"const styles = StyleSheet.create({",
"\tcontainer: {",
"\t\tflex: 1,",
"\t\tpadding: 16,",
"\t}",
"});"
],
"description": "React native component"
},
"React Native static image": {
"prefix": "rnimg",
"body": [
"<Image source={require('.${path}')}/>"
],
"description": "React Native image compoent with static source (require)"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment