Last active
December 28, 2015 03:27
-
-
Save grabcode/311002dcc14c2bb18b7c to your computer and use it in GitHub Desktop.
ReactNative Component and Styles Snippet
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
'.source.js': | |
'ReactNative Component': | |
'prefix': 'rnc' | |
'body': """ | |
'use strict'; | |
import React, { | |
Text, | |
} from 'react-native'; | |
class ${1:Component} extends React.Component { | |
render() { | |
return ( | |
$2 | |
); | |
} | |
} | |
export default ${1:Component}; | |
""" | |
'Import Styles': | |
'prefix': 'is' | |
'body': "import styles from './styles';" | |
'ReactNative Style': | |
'prefix': 'rns' | |
'body': """ | |
'use strict'; | |
import React, { | |
StyleSheet, | |
} from 'react-native'; | |
module.exports = StyleSheet.create({ | |
${1:Attribute}: ${2:Value}, | |
}); | |
""" | |
'React Native Stateless Function': | |
'prefix': 'rnsf' | |
'body': """ | |
'use strict'; | |
import React, { | |
Text, | |
} from 'react-native'; | |
export default function(props){ | |
return ( | |
<${1:Component}> | |
$2 | |
</${1:Component}> | |
); | |
}; | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notes
Very quickly, you'll want to split up the component tag from its style. Here is a way to start: in the same component folder, you are invited to create 2 files, a
$componentName.js
, and astyles.js
. The$componentName.js
import the corresponding styles throughimport styles from './styles';
.Usage
Example
Add your snippet into Atom