参考地址: 超级吴小迪
- rcc + tab键 - - 用ES6模块系统创建一个React组件类
class Index extends Component {
render() {
return (
<div>
</div>
);
}
}
export default Index;
- rccp + tab键 - - 创建一个带有PropTypes和ES6模块系统的React组件类
class Index extends Component {
render() {
return (
<div>
</div>
);
}
}
Index.propTypes = {};
export default Index;
- rcfc + tab键 - - 创建一个带有PropTypes和所有生命周期方法以及ES6模块系统的React组件类
import React, {Component} from 'react';
import PropTypes from 'prop-types';
class Index extends Component {
constructor(props) {
super(props);
}
componentWillMount() {}
componentDidMount() {}
componentWillReceiveProps(nextProps) {}
shouldComponentUpdate(nextProps, nextState) {}
componentWillUpdate(nextProps, nextState) {}
componentDidUpdate(prevProps, prevState) {}
componentWillUnmount() {}
render() {
return (
<div>
</div>
);
}
}
Index.propTypes = {};
export default Index;
- rcjc + tab键 - - 用ES6模块系统创建一个React组件类(无导出)
class Index extends Component {
render() {
return (
<div>
</div>
);
}
}
下面的自己可以尝试一下哦,笔者只是做了介绍就不放图了~
- rdp + tab键 - - 快速生成defaultProps
.defaultProps = {
};
- rpc + tab键 - - 用PropTypes和ES6 moudle系统创建一个React纯组件类
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
class Index extends PureComponent {
render() {
return (
<div>
</div>
);
}
}
Index.propTypes = {};
export default Index;
- rrc + tab键 - - 创建一个连接到redux的React组件类
import React, {Component} from 'react';
import {connect} from 'react-redux';
function mapStateToProps(state) {
return {};
}
class Index extends Component {
render() {
return (
<div>
</div>
);
}
}
export default connect(
mapStateToProps,
)(Index);
- rrdc + tab键 - - 创建一个通过dispatch连接到redux的React组件类
import React, {Component} from 'react';
import {connect} from 'react-redux';
function mapStateToProps(state) {
return {};
}
function mapDispatchToProps(dispatch) {
return {};
}
class Index extends Component {
render() {
return (
<div>
</div>
);
}
}
export default connect(
mapStateToProps,
)(Index);
- rsc + tab键 - - 创建没有PropTypes和ES6模块系统的无状态React组件
import React from 'react';
const Index = () => {
return (
<div>
</div>
);
};
export default Index;
- rscp + tab键 - - 创建有PropTypes和ES6模块系统的无状态React组件
import React from 'react';
import PropTypes from 'prop-types';
const Index = props => {
return (
<div>
</div>
);
};
Index.propTypes = {
};
export default Index;
- rsf + tab键 - - 以命名函数的形式创建无状态的React组件,不使用PropTypes
import React from 'react';
function Index(props) {
return (
<div></div>
);
}
export default Index;
- rsfp + tab键 - - 使用PropTypes将无状态的React组件作为命名函数创建
import React from 'react';
import PropTypes from 'prop-types';
Index.propTypes = {
};
function Index(props) {
return (
<div></div>
);
}
export default Index;
- rsi + tab键 - - 创建无状态的React组件,不使用PropTypes和ES6模块系统,但使用隐式返回和道具
import React from 'react';
const Index = (props) => (
);
export default Index;
- rwwd + tab键 - - 在没有导入的情况下,在ES6模块系统中创建一个有构造函数、空状态、proptypes和导出的React组件类。(主要用于React时,proptype由webpack提供插件提供)
class Index extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div>
</div>
);
}
}
Index.propTypes = {};
export default Index;
网友评论