Last active
March 9, 2020 14:27
-
-
Save SpencerCDixon/8af0cff45a8ebff082f9 to your computer and use it in GitHub Desktop.
React ES6 Vim Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet it | |
it("${1}", function() { | |
${2} | |
}); | |
snippet desc | |
describe("${1}", function() { | |
${2} | |
}); | |
snippet con | |
constructor(props) { | |
super(props); | |
${0} | |
} | |
snippet bef | |
beforeEach(() => { | |
${1} | |
}); | |
snippet afe | |
afterEach(() => { | |
${1} | |
}); | |
snippet sandbox | |
let sandbox; | |
beforeEach(() => { | |
sandbox = sinon.sandbox.create(); | |
}); | |
afterEach(() => { | |
sandbox.restore(); | |
}); | |
snippet redt | |
const initialState = {${1}}; | |
deepFreeze(initialState); | |
const action = { | |
type: ${2} | |
}; | |
const nextState = { | |
${3} | |
}; | |
expect(reducer(initialState, action)).to.eql(nextState); | |
snippet thnk | |
export const ${1} = () => { | |
return (dispatch, getState) => { | |
${0} | |
}; | |
}; | |
snippet cls | |
import React, { Component, PropTypes } from 'react'; | |
const propTypes = { | |
}; | |
class ${1:ClassName} extends Component { | |
render() { | |
return ( | |
${0} | |
) | |
} | |
} | |
$1.propTypes = propTypes; | |
export default $1; | |
snippet fcls | |
function ${1:ClassName} ({ ${2 }}) { | |
return ( | |
${0} | |
) | |
} | |
$1.propTypes = propTypes; | |
export default $1; | |
snippet ccls | |
import React, { Component, PropTypes } from 'react'; | |
import { connect } from 'react-redux'; | |
import { bindActionCreators } from 'redux'; | |
const propTypes = { | |
}; | |
class ${1:ClassName} extends Component { | |
render() { | |
return ( | |
${0} | |
) | |
} | |
} | |
function mapStateToProps(state) { | |
return {}; | |
} | |
function mapDispatchToProps(dispatch) { | |
return {}; | |
} | |
$1.propTypes = propTypes; | |
export default connect( | |
mapStateToProps, | |
mapDispatchToProps | |
)($1); | |
snippet bcls | |
import React from 'react'; | |
import BaseComponent from ${2:'../BaseComponent'}; | |
class ${1:ClassName} extends BaseComponent { | |
constructor(props) { | |
super(props); | |
this._bind(); | |
${0} | |
} | |
render() { | |
} | |
} | |
export default $1 | |
snippet rmod | |
// Constants | |
${0} | |
export const constants = { | |
}; | |
// Action Creators | |
export const actions = { | |
}; | |
// Reducer | |
export const defaultState = { | |
}; | |
export default function(state = defaultState, action) { | |
switch (action.type) { | |
default: | |
return state; | |
} | |
} | |
snippet req | |
import React from 'react'; | |
snippet breq | |
import React from 'react'; | |
import BaseComponent from './BaseComponent'; | |
snippet pty | |
const propTypes = { | |
${1} | |
}; | |
snippet imp | |
import ${1} from ${2}; | |
snippet impc | |
import { ${1} } from ${2}; | |
snippet impb | |
import BaseComponent from ${1:'../BaseComponent'}; | |
snippet p= | |
${1}.propTypes = propTypes; | |
snippet ren | |
render() { | |
${0} | |
} | |
snippet cdm | |
componentDidMount() { | |
${0} | |
} | |
snippet exp | |
export default ${1} | |
snippet bm | |
this._bind('${0}') | |
snippet re | |
return ( | |
${0} | |
) | |
snippet rptf | |
React.PropTypes.func | |
snippet pts | |
PropTypes.string | |
snippet ptn | |
PropTypes.number | |
snippet pta | |
PropTypes.array | |
snippet pto | |
PropTypes.object | |
snippet pte | |
PropTypes.element | |
snippet ptb | |
PropTypes.bool | |
snippet ptf | |
PropTypes.func | |
snippet ptc | |
PropTypes.children = PropTypes.oneOfType([ | |
PropTypes.node, | |
PropTypes.arrayOf(PropTypes.node), | |
]); | |
snippet act | |
export const ${1:ActionName} = '$1'; | |
snippet desc | |
describe('${1}', () => { | |
${0} | |
}); | |
snippet it | |
it('${1}', () => { | |
${0} | |
}); | |
snippet c | |
const ${1} = ${0}; | |
snippet l | |
let ${1} = ${0}; | |
snippet expect | |
expect(${1}).to.${2}(${0}); | |
snippet bf | |
this.${1:handleFunc} = this.${1}.bind(this); | |
snippet log | |
console.log(${0}); | |
snippet wd | |
console.log(wrapper.debug()); | |
snippet mstp | |
function mapStateToProps(state) { | |
return { | |
${0} | |
} | |
} | |
snippet mdtp | |
function mapDispatchToProps(dispatch) { | |
return { | |
${0} | |
} | |
} | |
snippet h1 | |
<h1>${0}</h1> | |
snippet h2 | |
<h2>${0}</h2> | |
snippet h3 | |
<h3>${0}</h3> | |
snippet h4 | |
<h4>${0}</h4> | |
snippet h5 | |
<h5>${0}</h5> | |
snippet h6 | |
<h6>${0}</h6> | |
snippet div | |
<div>${0}</div> | |
snippet divc | |
<div className=${1}>${0}</div> | |
snippet p | |
<p>${0}</p> | |
snippet rw | |
<Row>${0}</Row> | |
snippet gd | |
<Grid>${0}</Grid> | |
snippet col | |
<Col>${0}</Col> | |
snippet li | |
<li>${0}</li> | |
snippet ul | |
<ul> | |
<li>${0}</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment