jeantimex / react-sublime-snippet

Save time in writing React codes
MIT License
103 stars 24 forks source link

RFC Functional Component and React 15.5+ #8

Open audetcameron opened 3 years ago

audetcameron commented 3 years ago

https://reactjs.org/docs/typechecking-with-proptypes.html "Note: React.PropTypes has moved into a different package since React v15.5. Please use the prop-types library instead."

The new syntax is

import React from 'react';
import PropTypes from 'prop-types'; // ES6

const Component = ({ className }) => {
    return (

    );
};

Component.displayName = 'Component';

Component.propTypes = {
    className: PropTypes.string,
};

export default Component;

the package renders


import React, { PropTypes } from 'react';

const Component = ({ className }) => {
    return (

    );
};

Component.displayName = 'Component';

Component.propTypes = {
    className: PropTypes.string,
};

export default Component;

which will throw an error on prop-types.

Would it be worth adding another generator schema for this new syntax?