Skip to content

Instantly share code, notes, and snippets.

@rt2zz
Created August 15, 2015 05:57
Show Gist options
  • Save rt2zz/65e0c4e7c4cb838c25ca to your computer and use it in GitHub Desktop.
Save rt2zz/65e0c4e7c4cb838c25ca to your computer and use it in GitHub Desktop.
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
{
".source.js":
"Common Actions: require lodash":
prefix: "lodash"
body: "import _ from 'lodash'"
"Common Actions: RGBA White":
prefix: "white"
body: "rgba(255,255,255,${1:1})"
"Common Actions: RGBA Black":
prefix: "black"
body: "rgba(0,0,0,${1:1})"
"React: componentDidMount: fn() { ... }":
prefix: "cdm"
body: "componentDidMount() {\n\t${1}\n}"
"React: componentDidUpdate: fn(pp, ps) { ... }":
prefix: "cdu"
body: "componentDidUpdate(prevProps, prevState) {\n\t${1}\n},"
"React: componentWillMount: fn() { ... }":
prefix: "cwm"
body: "componentWillMount() {\n\t${1}\n}"
"React: componentWillUnmount: fn() { ... }":
prefix: "cwmu"
body: "componentWillUnmount() {\n\t${1}\n}"
"React: componentWillReceiveProps: fn(np) { ... }":
prefix: "cwrp"
body: "componentWillReceiveProps(nextProps) {\n\t${1}\n}"
"React: componentWillUpdate: fn(np, ns) { ... }":
prefix: "cwu"
body: "componentWillUpdate(nextProps, nextState) {\n\t${1}\n},"
"React: getInitialState: fn() { return {...} } ":
prefix: "gis"
body: "state = {${1}}"
"React: propTypes { ... }":
prefix: "rpt"
body: "propTypes = {\n\t${1}: React.PropTypes.${2:string}\n},"
"React: setState({ ... })":
prefix: "rss"
body: "this.setState({\n\t${1}: ${2}\n})"
"React: contextTypes":
prefix: "rct"
body: "contextTypes: {\n\t${1}: React.PropTypes.${2}\n}\n"
"Redux: connector":
prefix: "reduxnativeconnect"
body: """
import ${1} from './${2}'
import { connect } from 'react-redux/native'
export default connect(
state => ({ ...state.${3}}),
)(${1})
"""
"Redux: build reducer skeleton":
prefix: 'buildreducer'
body: """
import { ${3} } from '../constants/ActionTypes'
const initialState = {${2}}
export default function ${1}(state = initialState, action) {
switch (action.type) {
case ${3}:
return state
default:
return state
}
}
"""
"React: build component skeleton":
prefix: "buildrct"
body: """
import React, { Component } from 'react'
export default class ${1} extends Component {
render() {
return (
<div>
${2}
</div>
)
}
}
"""
"React: build react native component skeleton":
prefix: "buildrn"
body: """
import React, { Component, View, Text, StyleSheet} from 'react-native'
export default class ${1} extends Component {
render() {
return (
${0:<View>
${2}
</View>}
)
}
}
const styles = StyleSheet.create({\n})
"""
"Redux: Reducer":
prefix: "reduxr"
body: """
import { ${2} } from '../constants/ActionTypes'
const initialState = {
${3}
}
export default function ${1}(state = initialState, action) {
switch (action.type) {
${4}
default:
return state
}
}
"""
"Redux: Reducer Index":
prefix: "reduxri"
body: """
export { default as app } from './app'
"""
"Redux: ActionTypes":
prefix: "reduxat"
body: """
//app
export const INITIALIZE = 'INITIALIZE'
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment