layershifter / babel-plugin-transform-react-handled-props

Generates handledProps from defaultProps and propTypes during the build :sparkles:
MIT License
19 stars 4 forks source link

Did not get `propTypes ` #33

Open simonguo opened 6 years ago

simonguo commented 6 years ago

in

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

const propTypes={
  children: PropTypes.node,
  className: PropTypes.string
}

function Example() {
  return <div />;
}

Example.propTypes = propTypes;

export default Example;

out

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

const propTypes = {
  children: PropTypes.node,
  className: PropTypes.string
};

function Example() {
  return <div />;
}

Example.handledProps = [];
Example.propTypes = propTypes;

export default Example;
simonguo commented 6 years ago

https://github.com/simonguo/babel-plugin-transform-react-flow-handled-props/blob/6285a377f8c281d6ba56eae6812f581408187ee9/src/visitors/propVisitor.js#L67

layershifter commented 6 years ago

It will be awesome to get PR that adds this functionality 👍 BTW, there is an easier way to get bindings 😸

simonguo commented 6 years ago

@layershifter Thank you so much, I will take a closer look at the babel Document!