After install this snippets add this inside your settings
"editor.snippetSuggestions": "top",
| Snippets | Content |
|---|---|
| imr | Import React |
| imrc | Import React Component |
| imrn | Import React-Native Element |
| ims | Import Styled-Components |
| imsn | Import Styled-Components Native |
| rct | Redux constant |
| crr | Connect Redux |
| sl | Stateless Component |
| slc | Stateless Component Function |
| ccs | Component Class |
| edccs | Export default Component Class |
| rrd | Redux Reducer |
| rpf | Redux Pure Function |
| rpc | Redux Pure Function Const |
| cwm | ComponentWillMount |
| cdm | ComponentDidMount |
| cdu | ComponentDidUpdate |
| cwu | ComponentWillUpdate |
| cwum | ComponentWillUnmount |
| cwrp | ComponentWillReceiveProps |
| ess | EStyleSheet Style |
| ed | Export default |
| edl | EslintDisableLine |
| styc | Styled Component |
| estyc | Export Styled Component |
| edstyc | Export default Styled Component |
| cmmb | Comment Big Block |
| log | Console Log |
| tdesc | Test Describe |
| tit | Test It |
Below is a list of all available snippets and the triggers of each one. The ⇥ means the TAB key.
| Trigger | Content |
|---|---|
rcc→ |
class component skeleton |
rccp→ |
class component skeleton with prop types after the class |
rcjc→ |
class component skeleton without import and default export lines |
rcfc→ |
class component skeleton that contains all the lifecycle methods |
rsc→ |
stateless component skeleton |
rscp→ |
stateless component with prop types skeleton |
rpt→ |
empty propTypes declaration |
con→ |
class default constructor with props |
conc→ |
class default constructor with props and context |
est→ |
empty state object |
ren→ |
render method |
sst→ |
this.setState with object as parameter |
ssf→ |
this.setState with function as parameter |
props→ |
this.props |
state→ |
this.state |
bnd→ |
binds the this of method inside the constructor |
rrcon→ |
reactReduxContainer |
The following table lists all the snippets that can be used for prop types.
Every snippet regarding prop types begins with pt so it's easy to group it all together and explore all the available options.
On top of that each prop type snippets has one equivalent when we need to declare that this property is also required.
For example pta creates the PropTypes.array and ptar creates the PropTypes.array.isRequired
| Trigger | Content |
|---|---|
pta→ |
PropTypes.array, |
ptar→ |
PropTypes.array.isRequired, |
ptb→ |
PropTypes.bool, |
ptbr→ |
PropTypes.bool.isRequired, |
ptf→ |
PropTypes.func, |
ptfr→ |
PropTypes.func.isRequired, |
ptn→ |
PropTypes.number, |
ptnr→ |
PropTypes.number.isRequired, |
pto→ |
PropTypes.object., |
ptor→ |
PropTypes.object.isRequired, |
pts→ |
PropTypes.string, |
ptsr→ |
PropTypes.string.isRequired, |
ptnd→ |
PropTypes.node, |
ptndr→ |
PropTypes.node.isRequired, |
ptel→ |
PropTypes.element, |
ptelr→ |
PropTypes.element.isRequired, |
pti→ |
PropTypes.instanceOf(ClassName), |
ptir→ |
PropTypes.instanceOf(ClassName).isRequired, |
pte→ |
PropTypes.oneOf(['News', 'Photos']), |
pter→ |
PropTypes.oneOf(['News', 'Photos']).isRequired, |
ptet→ |
PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
ptetr→ |
PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired, |
ptao→ |
PropTypes.arrayOf(PropTypes.number), |
ptaor→ |
PropTypes.arrayOf(PropTypes.number).isRequired, |
ptoo→ |
PropTypes.objectOf(PropTypes.number), |
ptoor→ |
PropTypes.objectOf(PropTypes.number).isRequired, |
ptsh→ |
PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}), |
ptshr→ |
PropTypes.shape({color: PropTypes.string, fontSize: PropTypes.number}).isRequired, |
import React from 'react';import React, { Component } from 'react';import { $1 } from 'react-native';import styled from 'styled-components';import styled from 'styled-components/native';export const $1 = '$1';import { connect } from 'react-redux';const $1 = () => (
$2
);
export default $1;function $1($2) {
$3
}
export default $1;class $1 extends Component {
state = { $2 }
render() {
return (
$3
);
}
}
export default $1;export default class $1 extends Component {
state = { $2 }
render() {
return (
$3
);
}
}export default (state = $1, action) => {
switch (action.type) {
case $2:
$3
default:
return state;
}
};export const $1 = '$1';
export function $2($3) {
return {
type: $1,
$3
}
}export const $1 = '$1';
export const $2 = $3 => ({
type: $1,
$3
});componentWillMount() {
$1
}componentWillUpdate() {
$1
}componentDidUpdate(prevProps, prevState) {
$1
}componentDidMount() {
$1
}componentWillUnmount() {
$1
}componentWillReceiveProps(nextProps) {
$1
}import EStyleSheet from 'react-native-extended-stylesheet';
const styles = EStyleSheet.create({
$1
});
export default styles;export default $1;// eslint-disable-lineconst $1 = styled.$2`
$3
`export const $1 = styled.$2`
$3
`export default styled.$1`
$2
`/**
|--------------------------------------------------
| $1
|--------------------------------------------------
*/console.log('====================================');
console.log($1);
console.log('====================================');describe('$1', () => {
$2
});it('should $1', $2($3) => {
$4
});