Skip to content

Instantly share code, notes, and snippets.

@ptquang86
Created April 2, 2018 00:43
Show Gist options
  • Save ptquang86/8256105bad84d96d22890fb9841bdfa5 to your computer and use it in GitHub Desktop.
Save ptquang86/8256105bad84d96d22890fb9841bdfa5 to your computer and use it in GitHub Desktop.
{
"Quang log": {
"prefix": "ql",
"body": [
"Ti.API.error('Quang: $1 ' + JSON.stringify( ${2:1} ));$3"
]
},
"WinManager load": {
"prefix": "load",
"body": [
"Alloy.Globals.WinManager.load({ ",
" url: '$1',",
" data: { $2 },",
" reset: ${3:false}",
"});$4"
]
},
"WinManager loadPrevious": {
"prefix": "loadp",
"body": [
"Alloy.Globals.WinManager.loadPrevious($1);$2"
]
},
"React Native Component File": {
"prefix": "rnc",
"body": [
"// @flow",
"",
"import * as React from 'react'",
"import {",
" StyleSheet,",
" Text,",
" View",
"} from 'react-native'",
"",
"// ==",
"",
"type TP_${1:MyComponent} = {",
" // foo: number,",
" // bar?: string",
"}",
"",
"type TS_${1} = {",
" // value: number",
"}",
"",
"class ${1} extends React.Component<TP_${1}, TS_${1}> {",
" // static defaultProps = {",
" // foo: 42",
" // }",
"",
" // state = {",
" // value: 0",
" // }",
"",
" // constructor(props: TP_${1}) { super(props) }",
" // componentWillMount() {}",
" // // render() {}",
" // componentDidMount() {}",
" // componentWillReceiveProps(nextProps) {}",
" // shouldComponentUpdate(nextProps, nextState) { return true }",
" // componentWillUpdate(nextProps, nextState) {}",
" // // render() {}",
" // componentDidUpdate(prevProps, prevState) {}",
" // componentWillUnmount() {}",
"",
" render() {",
" return ${2:<View style={styles.container\\}>",
" ${3:<Text>${4:Im the ${1} component}</Text>}",
" <Text>{this.state.value\\}</Text>",
" </View>}$5",
" }",
"}",
"",
"const styles = StyleSheet.create({",
" container: { flex: 1 }",
"})",
"",
"export default ${1}"
]
},
"React Native Pure Component File": {
"prefix": "rncp",
"body": [
"// @flow weak",
"",
"import * as React from 'react'",
"import {",
" StyleSheet,",
" TextInput,",
" View",
"} from 'react-native'",
"",
"type T_Props = {",
" ${2:value}: string,",
" ${3:onChange}: Function",
"}",
"",
"const ${1:MyComponent} = ({ ${2:value}, ${3:onChange} }: T_Props) =>",
" ${4:<View style={styles.container\\}>",
" ${5:<TextInput style={styles.textfield\\} value={${2:value}\\}",
" onChangeText={${3:onChange}\\}/>}",
" </View>}$7",
"",
"// ${1:MyComponent}.defaultProps = {",
"// ${2:value}: 'TODO: default value'",
"// }",
"",
"const styles = StyleSheet.create({",
" container: { flex: 1 },",
" textfield: {}",
"})",
"",
"export default ${1:MyComponent}"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment