1
0
Fork 0
mirror of synced 2024-11-10 11:18:58 -05:00
ultimate-vim/sources_non_forked/vim-snippets/snippets/javascript-es6-react.snippets

83 lines
1.1 KiB
Text
Raw Normal View History

2016-11-09 12:22:55 -05:00
# Import only React
snippet ri1
import React from 'react'
# Import both React and Component
snippet ri2
2017-07-06 08:57:35 -04:00
import React, { Component } from 'react'
import PropTypes from 'prop-types'
2016-11-09 12:22:55 -05:00
# React class
snippet rcla
class ${1:MyComponent} extends Component {
render() {
return (
${0:<div></div>}
)
}
}
# React constructor
snippet rcon
constructor(props) {
super(props)
this.state = {
${1}: ${0},
}
}
# Proptypes for React Class
snippet rcpt
static propTypes = {
${1}: PropTypes.${0},
}
# Default props for React Class
snippet rcdp
static defaultProps = {
${1}: ${0},
}
# Presentational component
snippet rcom
2017-07-06 08:57:35 -04:00
props => {
2016-11-09 12:22:55 -05:00
return (
${0:<div></div>}
)
}
# Proptypes for Presentational component
snippet rpt
${1}.propTypes = {
${2}: PropTypes.${0},
}
# Default props for Presentational component
snippet rdp
${1}.defaultProps = {
${2}: ${0},
}
# Lifecycle Methods
snippet rcdm
componentDidMount() {
2017-02-11 08:01:38 -05:00
${0:${VISUAL}}
2016-11-09 12:22:55 -05:00
}
# State
snippet rsst
this.setState({
${1}: ${0},
})
snippet rtst
this.state.${0}
# Props
snippet rp
props.${0}
snippet rtp
this.props.${0}