Skip to content

Instantly share code, notes, and snippets.

@johncmunson
Created February 16, 2017 09:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johncmunson/fa5d46488e48ee2c34e2ed818370900b to your computer and use it in GitHub Desktop.
Save johncmunson/fa5d46488e48ee2c34e2ed818370900b to your computer and use it in GitHub Desktop.
'JSX comment':
'prefix': 'reJSXComment'
'body': '{/* ${1:Comments...} */}'
'ReactDOM.render':
'prefix': 'reDOMRender'
'body': 'ReactDOM.render(${1:<App />}, document.getElementById(\'${2:root}\'));'
'class component w/ extras':
'prefix': 'reCompFull'
'body': """
class ${1:Component} extends React.Component {
static propTypes = {
// require and typecheck certain props
}
static defaultProps = {
// set defaults
}
autoBoundMethod = () => {
// use with {this.autoBoundMethod}
}
constructor(props) {
super(props)
this.state = {
// set initial state
}
}
componentWillMount() {
}
componentDidMount() {
// make API calls here
}
componentWillReceiveProps(newProps) {
}
shouldComponentUpdate(newProps, newState) {
}
componentWillUpdate(nextProps, nextState) {
}
componentDidUpdate(prevProps, prevState) {
}
componentWillUnmount() {
}
render() {
return (
${2:<div></div>}
);
}
}
"""
'class component':
'prefix': 'reCompClass'
'body': """
class ${1:Component} extends React.Component {
render() {
return (
${2:<div></div>}
);
}
}
"""
'functional component':
'prefix': 'reCompFunc'
'body': """
const ${1:Component} = (props) => (
${2:<div></div>}
);
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment