Sublime ES7 React Redux ReactNative JS代码片段
Sublime ES7 React/Redux/React-Native/JS代码片段
详细信息
安装次数
- 总数 29K
- Win 20K
- Mac 4K
- Linux 5K
Aug 6 | Aug 5 | Aug 4 | Aug 3 | Aug 2 | Aug 1 | Jul 31 | Jul 30 | Jul 29 | Jul 28 | Jul 27 | Jul 26 | Jul 25 | Jul 24 | Jul 23 | Jul 22 | Jul 21 | Jul 20 | Jul 19 | Jul 18 | Jul 17 | Jul 16 | Jul 15 | Jul 14 | Jul 13 | Jul 12 | Jul 11 | Jul 10 | Jul 9 | Jul 8 | Jul 7 | Jul 6 | Jul 5 | Jul 4 | Jul 3 | Jul 2 | Jul 1 | Jun 30 | Jun 29 | Jun 28 | Jun 27 | Jun 26 | Jun 25 | Jun 24 | Jun 23 | Jun 22 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 3 | 3 | 2 | 0 | 3 | 5 | 1 | 3 | 1 | 2 | 0 | 0 | 4 | 6 | 4 | 3 | 2 | 1 | 3 | 5 | 5 | 1 | 1 | 1 | 3 | 1 | 1 | 0 | 3 | 3 | 4 | 3 | 2 | 4 | 2 | 2 | 4 | 2 | 5 | 2 | 2 | 0 | 2 | 0 | 2 | 2 |
Mac | 1 | 1 | 0 | 0 | 0 | 3 | 3 | 1 | 3 | 2 | 3 | 0 | 1 | 2 | 2 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 2 | 2 | 0 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 0 | 0 | 0 | 1 | 2 | 1 | 1 | 0 | 0 | 0 | 3 |
Linux | 0 | 1 | 0 | 0 | 2 | 3 | 0 | 1 | 0 | 2 | 0 | 0 | 0 | 2 | 0 | 0 | 2 | 0 | 3 | 0 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 4 | 1 | 2 | 2 | 1 | 0 | 1 | 0 | 1 | 2 | 1 | 2 | 0 | 0 | 0 | 1 | 0 |
读我
Sublime ES7 React/Redux/React-Native/JS代码片段 (适用于JS和TS)
本Sublime扩展将来自“VS Code ES7 React/Redux/React-Native/JS代码片段”的优秀并受欢迎的代码片段集合移植到Sublime。VS Code扩展中的代码片段位于scr/snippets.json
中,将代码片段转换为Sublime代码片段格式的脚本在src/index.js
中,完成的Sublime代码片段位于snippets/
文件夹中。代码片段适用于TypeScript和JavaScript。
请注意,所有{ PureComponent }
或{ Component }
都已替换为...extends React.PureComponent
或...extends React.Component
。
总共有148个
安装
通过Package Control安装。
- 使用
Ctrl/⌘+Shift+p
打开命令面板。 - 选择Package Control: 安装包
- 搜索
Sublime ES7 React/Redux/React-Native/JS代码片段
并按Enter键
片段信息复制/粘贴自:“VS Code ES7 React/Redux/React-Native/JS snippets”
代码片段中{ }
和( )
内部的所有空格都表示它将被推到下一行:) $
代表每个步骤后的tab
。
基本方法
前缀 | 方法 |
---|---|
imp→ |
import moduleName from 'module' |
imn→ |
import 'module' |
imd→ |
import { destructuredModule } from 'module' |
ime→ |
import * as alias from 'module' |
ima→ |
import { originalName as aliasName} from 'module' |
exp→ |
export default moduleName |
exd→ |
export { destructuredModule } from 'module' |
exa→ |
export { originalName as aliasName} from 'module' |
enf→ |
export const functionName = (params) => { } |
edf→ |
export default (params) => { } |
met→ |
methodName = (params) => { } |
fre→ |
arrayName.forEach(element => { } |
fof→ |
for(let itemName of objectName { } |
fin→ |
for(let itemName in objectName { } |
anfn→ |
(params) => { } |
nfn→ |
const functionName = (params) => { } |
dob→ |
const {propName} = objectToDescruct |
dar→ |
const [propName] = arrayToDescruct |
sti→ |
setInterval(() => { }, intervalTime |
sto→ |
setTimeout(() => { }, delayTime |
prom→ |
return new Promise((resolve, reject) => { } |
cmmb→ |
注释块 |
cp→ |
const { } = this.props |
cs→ |
const { } = this.state |
React
前缀 | 方法 |
---|---|
imr→ |
import React from 'react' |
imrd→ |
import ReactDOM from 'react-dom' |
imrc→ |
import React, { Component } from 'react' |
imrcp→ |
import React, { Component } from 'react' & import PropTypes from 'prop-types' |
imrpc→ |
import React, { PureComponent } from 'react' |
imrpcp→ |
import React, { PureComponent } from 'react' & import PropTypes from 'prop-types' |
imrm→ |
import React, { memo } from 'react' |
imrmp→ |
import React, { memo } from 'react' & import PropTypes from 'prop-types' |
impt→ |
import PropTypes from 'prop-types' |
imrr→ |
import { BrowserRouter as Router, Route, Link } from 'react-router-dom' |
redux→ |
import { connect } from 'react-redux' |
rconst→ |
constructor(props) with this.state |
rconc→ |
constructor(props, context) with this.state |
est→ |
this.state = { } |
cwm→ |
componentWillMount = () => { } 已弃用!!! |
cdm→ |
componentDidMount = () => { } |
cwr→ |
componentWillReceiveProps = (nextProps) => { } 已弃用!!! |
scu→ |
shouldComponentUpdate = (nextProps, nextState) => { } |
cwup→ |
componentWillUpdate = (nextProps, nextState) => { } 已弃用!!! |
cdup→ |
componentDidUpdate = (prevProps, prevState) => { } |
cwun→ |
componentWillUnmount = () => { } |
gdsfp→ |
static getDerivedStateFromProps(nextProps, prevState) { } |
gsbu→ |
getSnapshotBeforeUpdate = (prevProps, prevState) => { } |
ren→ |
render() { return( ) } |
sst→ |
this.setState({ }) |
ssf→ |
this.setState((state, props) => return { }) |
props→ |
this.props.propName |
state→ |
this.state.stateName |
rcontext→ |
const ${1:contextName} = React.createContext() |
cref→ |
this.${1:refName}Ref = React.createRef() |
fref→ |
const ref = React.createRef() |
bnd→ |
this.methodName = this.methodName.bind(this) |
React Hooks
- 所有 hooks 从 官方文档 都添加了钩子名称前缀。
React Native
前缀 | 方法 |
---|---|
imrn→ |
import { $1 } from 'react-native' |
rnstyle→ |
const styles = StyleSheet.create({}) |
Redux
前缀 | 方法 |
---|---|
rxaction→ |
redux action 模板 |
rxconst→ |
export const $1 = '$1' |
rxreducer→ |
redux reducer 模板 |
rxselect→ |
redux selector 模板 |
PropTypes
前缀 | 方法 |
---|---|
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(name) |
ptir→ |
PropTypes.instanceOf(name).isRequired |
pte→ |
PropTypes.oneOf([name]) |
pter→ |
PropTypes.oneOf([name]).isRequired |
ptet→ |
PropTypes.oneOfType([name]) |
ptetr→ |
PropTypes.oneOfType([name]).isRequired |
ptao→ |
PropTypes.arrayOf(name) |
ptaor→ |
PropTypes.arrayOf(name).isRequired |
ptoo→ |
PropTypes.objectOf(name) |
ptoor→ |
PropTypes.objectOf(name).isRequired |
ptsh→ |
PropTypes.shape({ }) |
ptshr→ |
PropTypes.shape({ }).isRequired |
ptany→ |
PropTypes.any |
ptypes→ |
static propTypes = {} |
GraphQL
|graphql→
|import { compose, graphql } from 'react-apollo'
|
expgql
export default compose(graphql($1, { name: $2 }))($3);
控制台
前缀 | 方法 |
---|---|
clg→ |
console.log(object) |
clo→ |
console.log("object", object) |
ctm→ |
console.time("timeId") |
cte→ |
console.timeEnd("timeId") |
cas→ |
console.assert(expression,object) |
ccl→ |
console.clear() |
cco→ |
console.count(label) |
cdi→ |
console.dir |
cer→ |
console.error(object) |
cgr→ |
console.group(label) |
cge→ |
console.groupEnd() |
ctr→ |
console.trace(object) |
cwa→ |
console.warn |
cin→ |
console.info |
React 组件
rcc
import React, { Component } from 'react';
export default class FileName extends Component {
render() {
return <div>$2</div>;
}
}
rce
import React, { Component } from 'react';
export class FileName extends Component {
render() {
return <div>$2</div>;
}
}
export default $1;
rcep
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export class FileName extends Component {
static propTypes = {};
render() {
return <div>$2</div>;
}
}
export default $1;
rpc
import React, { PureComponent } from 'react';
export default class FileName extends PureComponent {
render() {
return <div>$2</div>;
}
}
rpcp
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
export default class FileName extends PureComponent {
static propTypes = {};
render() {
return <div>$2</div>;
}
}
rpce
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
export class FileName extends PureComponent {
static propTypes = {};
render() {
return <div>$2</div>;
}
}
export default FileName;
rccp
import React, { Component } from 'react';
import PropTypes from 'prop-types';
export default class FileName extends Component {
static propTypes = {
$2: $3,
};
render() {
return <div>$4</div>;
}
}
rfcp
import React from 'react';
import PropTypes from 'prop-types';
function $1(props) {
return <div>$0</div>;
}
$1.propTypes = {};
export default $1;
rfc
import React from 'react';
export default function $1() {
return <div>$0</div>;
}
rfce
import React from 'react';
function $1() {
return <div>$0</div>;
}
export default $1;
rafcp
import React from 'react';
import PropTypes from 'prop-types';
const $1 = props => {
return <div>$0</div>;
};
$1.propTypes = {};
export default $1;
rafc
import React from 'react';
const $1 = () => {
return <div>$0</div>;
};
export default $1;
rafce
import React from 'react';
const $1 = () => {
return <div>$0</div>;
};
export default $1;
rmc
import React, { memo } from 'react';
export default memo(function $1() {
return <div>$0</div>;
});
rmcp
import React, { memo } from 'react';
import PropTypes from 'prop-types';
const $1 = memo(function $1(props) {
return <div>$0</div>;
});
$1.propTypes = {};
export default $1;
rcredux
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
export class FileName extends Component {
static propTypes = {
$2: $3,
};
render() {
return <div>$4</div>;
}
}
const mapStateToProps = state => ({});
const mapDispatchToProps = {};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(FileName);
reduxmap
const mapStateToProps = state => ({});
const mapDispatchToProps = {};
React Native 组件
rnc
import React, { Component } from 'react';
import { Text, View } from 'react-native';
export default class FileName extends Component {
render() {
return (
<View>
<Text> $2 </Text>
</View>
);
}
}
rnf
import React from 'react';
import { View, Text } from 'react-native';
const $1 = () => {
return (
<View>
<Text> $2 </Text>
</View>
);
};
export default $1;
rncs
import React, { Component } from 'react';
import { Text, StyleSheet, View } from 'react-native';
export default class FileName extends Component {
render() {
return (
<View>
<Text> $2 </Text>
</View>
);
}
}
const styles = StyleSheet.create({});
rnce
import React, { Component } from 'react';
import { Text, View } from 'react-native';
export class FileName extends Component {
render() {
return (
<View>
<Text> $2 </Text>
</View>
);
}
}
export default $1;
rncredux
import React, { Component } from 'react';
import { View, Text } from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
export class FileName extends Component {
static propTypes = {
$2: $3,
};
render() {
return (
<View>
<Text> $2 </Text>
</View>
);
}
}
const mapStateToProps = state => ({});
const mapDispatchToProps = {};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(FileName);
其他
cmmb
/**
|--------------------------------------------------
| $1
|--------------------------------------------------
*/
desc
describe('$1', () => {
$2;
});
test
test('should $1', () => {
$2;
});
tit
it('should $1', () => {
$2;
});
stest
import React from 'react'
import renderer from 'react-test-renderer'
import { ${1:ComponentName} } from '../${1:ComponentName}'
describe('<${1:ComponentName} />', () => {
const defaultProps = {}
const wrapper = renderer.create(<${1:ComponentName} {...defaultProps} />)
test('render', () => {
expect(wrapper).toMatchSnapshot()
})
})
srtest
import React from 'react'
import renderer from 'react-test-renderer'
import { Provider } from 'react-redux'
import store from 'src/store'
import { ${1:ComponentName} } from '../${1:ComponentName}'
describe('<${1:ComponentName} />', () => {
const defaultProps = {}
const wrapper = renderer.create(
<Provider store={store}>
<${1:${TM_FILENAME_BASE}} {...defaultProps} />)
</Provider>,
)
test('render', () => {
expect(wrapper).toMatchSnapshot()
})
})
sntest
import 'react-native'
import React from 'react'
import renderer from 'react-test-renderer'
import ${1:ComponentName} from '../${1:ComponentName}'
describe('<${1:ComponentName} />', () => {
const defaultProps = {
}
const wrapper = renderer.create(<${1:ComponentName} {...defaultProps} />)
test('render', () => {
expect(wrapper).toMatchSnapshot()
})
})
snrtest
import 'react-native'
import React from 'react'
import renderer from 'react-test-renderer'
import { Provider } from 'react-redux'
import store from 'src/store/configureStore'
import ${1:ComponentName} from '../${1:ComponentName}'
describe('<${1:ComponentName} />', () => {
const defaultProps = {}
const wrapper = renderer.create(
<Provider store={store}>
<${1:ComponentName} {...defaultProps} />
</Provider>,
)
test('render', () => {
expect(wrapper).toMatchSnapshot()
})
})
hocredux
import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
export const mapStateToProps = state => ({
})
export const mapDispatchToProps = {
}
export const ${1:hocComponentName} = (WrappedComponent) => {
const hocComponent = ({ ...props }) => <WrappedComponent {...props} />
hocComponent.propTypes = {
}
return hocComponent
}
export default WrapperComponent => connect(mapStateToProps, mapDispatchToProps)(${1:hocComponentName}(WrapperComponent))
hoc
import React from 'react';
import PropTypes from 'prop-types';
export default WrappedComponent => {
const hocComponent = ({ ...props }) => <WrappedComponent {...props} />;
hocComponent.propTypes = {};
return hocComponent;
};