Skip to content

Instantly share code, notes, and snippets.

@tomsapps
Created November 9, 2016 02:33
Show Gist options
  • Select an option

  • Save tomsapps/0bef23b305d006261aba8724bcbd9a8d to your computer and use it in GitHub Desktop.

Select an option

Save tomsapps/0bef23b305d006261aba8724bcbd9a8d to your computer and use it in GitHub Desktop.
".source.js":
"PropTypes func isRequired":
prefix: "ptfi"
body: "PropTypes.func.isRequired,"
"PropTypes bool isRequired":
prefix: "ptbi"
body: "PropTypes.bool.isRequired,"
"PropTypes string isRequired":
prefix: "ptsi"
body: "PropTypes.string.isRequired,"
"PropTypes number isRequired":
prefix: "ptni"
body: "PropTypes.number.isRequired,"
"className":
prefix: "cn"
body: "className={$1}"
"onClick":
prefix: "oc"
body: "onClick={$1}"
"div className":
prefix: '.cn'
body: "<div className={$1}>$2</div>"
"div":
prefix: "."
body: "<div>$1</div>"
# Redux Course Snippets
"Redux Connect Skeleton":
prefix: "rc"
body: '''
import { bindActionCreators } from 'redux'
import { connect } from 'react-redux'
import { } from 'components'
function mapStateToProps (state, props) {
return {
}
}
function mapDispatchToProps (dispatch, props) {
return bindActionCreators( , dispatch)
}
export default connect(
mapStateToProps,
mapDispatchToProps
)()$1
'''
"React Component - Statefull":
prefix: "rccs"
body: '''
import React from 'react'
const ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}} = React.createClass({
render () {
return (
${0:<div></div>}
)
},
})
export default ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}}$2
'''
"React Stateless Functional Component Skeleton":
prefix: "rccf"
body: '''
import React, { PropTypes } from 'react'
export default function ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}} (props) {
return (
${0:<div></div>}
)
}$2
'''
# React Native Course Snippets
"React Native Stateless Functional Component Skeleton":
prefix: "rnccf"
body: '''
import React, { PropTypes } from 'react'
import { View, StyleSheet, Text } from 'react-native'
${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}}.propTypes = {
}
export default function ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}} (props) {
return (
${0:<View>
<Text>
${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}}
</Text>
</View>}
)
}
const styles = StyleSheet.create({
})$2
'''
"React Native Statefull Component Skeleton":
prefix: "rnccs"
body: '''
import React, { PropTypes, Component } from 'react'
import { View, Text } from 'react-native'
export default class ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}} extends Component {
static propTypes = {}
state = {}
render () {
return (
${0:<View>
<Text>
${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}}
</Text>
</View>}
)
}
}$2
'''
"Redux Module skeleton":
prefix: "duck"
body: '''
const initialState = {}
export default function ${1:${TM_FILENAME/(.?\\w*)(?:\\.\\w+)*$/$1/g}} (state = initialState, action) {
switch (action.type) {
default :
return state
}
}$2
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment