其他分享
首页 > 其他分享> > react快捷键

react快捷键

作者:互联网

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