Skip to content

Instantly share code, notes, and snippets.

@RJNY
Created December 16, 2016 22:32
Show Gist options
  • Save RJNY/209a31c6714760fc93c95dcb9c42863c to your computer and use it in GitHub Desktop.
Save RJNY/209a31c6714760fc93c95dcb9c42863c to your computer and use it in GitHub Desktop.
React Vim Snippets
#
# React snippets
#
snippet rnccf
import React, { PropTypes } from 'react'
import { View, StyleSheet, Text } from 'react-native'
$1.propTypes = {
}
export default function ${1:`!p snip.rv = snip.basename or "FunctionName"`} (props) {
return (
<View>
<Text>
$1
</Text>
</View>
)
}
const styles = StyleSheet.create({
$0
})
endsnippet
snippet rnccs
import React, { PropTypes, Component } from 'react'
import { View, Text } from 'react-native'
export default class ${1:`!p snip.rv = snip.basename or "ClassName"`} extends Component {
static propTypes = {}
state = {}
render () {
return (
${0:<View>
<Text>
$1
</Text>
</View>}
)
}
}
endsnippet
snippet duck
const initialState = {}
export default function ${1:`!p snip.rv = snip.basename or "FunctionName"`} (state = initialState, action) {
switch (action.type) {
default :
return state
}
}
endsnippet
snippet rc
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
)()
endsnippet
snippet rccs
import React from 'react'
const ${1:`!p snip.rv = snip.basename or "ClassName"`} = React.createClass({
render () {
return (
${0:<div></div>}
)
},
})
export default $1
endsnippet
snippet rccf
import React, { PropTypes } from 'react'
export default function ${1:`!p snip.rv = snip.basename or "FunctionName"`} (props) {
return (
${0:<div></div>}
)
}
endsnippet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment