标签:React return 快捷键 react tab Test import
rcc+tab键:用ES6模块系统创建一个React组件类
import React, {Component} from 'react';
class Test extends Component {
render() {
return (
<div>
</div>
);
}
}
export default Test;
rccp+tab键:创建一个带有PropTypes和ES6模块系统的React组件类
import React, {Component} from 'react';
import PropTypes from 'prop-types';
class Test extends Component {
render() {
return (
<div>
</div>
);
}
}
Test.propTypes = {};
export default Test;
rcfc+tab键:创建一个带有PropTypes和所有生命周期方法以及ES6模块系统的React组件类
import React, {Component} from 'react';
import PropTypes from 'prop-types';
class Test extends Component {
constructor(props) {
super(props);
}
componentWillMount() {
}
componentDidMount() {
}
componentWillReceiveProps(nextProps) {
}
shouldComponentUpdate(nextProps, nextState) {
}
componentWillUpdate(nextProps, nextState) {
}
componentDidUpdate(prevProps, prevState) {
}
componentWillUnmount() {
}
render() {
return (
<div>
</div>
);
}
}
Test.propTypes = {};
export default Test;
rcjc+tab键:用ES6模块系统创建一个React组件类(无导出)
class Test 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 Test extends PureComponent {
render() {
return (
<div>
</div>
);
}
}
Test.propTypes = {};
export default Test;
rrc+tab键:创建一个连接到redux的React组件类
import React, {Component} from 'react';
import {connect} from 'react-redux';
function mapStateToProps(state) {
return {};
}
class Test extends Component {
render() {
return (
<div>
</div>
);
}
}
export default connect(
mapStateToProps,
)(Test);
rrdc+tab键:创建一个通过dispatch连接到redux的React组件类
import React, {Component} from 'react';
import {connect} from 'react-redux';
function mapStateToProps(state) {
return {};
}
function mapDispatchToProps(dispatch) {
return {};
}
class Test extends Component {
render() {
return (
<div>
</div>
);
}
}
export default connect(
mapStateToProps,
)(Test);
rsc+tab键:创建没有PropTypes和ES6模块系统的无状态React组件
import React from 'react';
const Test = () => {
return (
<div>
</div>
);
};
export default Test;
rscp+tab键:创建有PropTypes和ES6模块系统的无状态React组件
import React from 'react';
import PropTypes from 'prop-types';
const Test = props => {
return (
<div>
</div>
);
};
Test.propTypes = {
};
export default Test;
rsf+tab键:以命名函数的形式创建无状态的React组件,不使用PropTypes
import React from 'react';
function Test(props) {
return (
<div></div>
);
}
export default Test;
rsfp+tab键:使用PropTypes将无状态的React组件作为命名函数创建
import React from 'react';
import PropTypes from 'prop-types';
Test.propTypes = {
};
function Test(props) {
return (
<div></div>
);
}
export default Test;
rsi+tab键:创建无状态的React组件,不使用PropTypes和ES6模块系统,但使用隐式返回和道具
import React from 'react';
const Test = (props) => (
);
export default Test;
rwwd+tab键:在没有导入的情况下,在ES6模块系统中创建一个有构造函数、空状态、proptypes和导出的React组件类。(主要用于React时,proptype由webpack提供插件提供)
class Test extends React.Component {
constructor(props) {
super(props);
this.state = {};
}
render() {
return (
<div>
</div>
);
}
}
Test.propTypes = {};
export default Test;
标签:React,return,快捷键,react,tab,Test,import 来源: https://www.cnblogs.com/ma1998/p/16655094.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。