react-bluekit icon indicating copy to clipboard operation
react-bluekit copied to clipboard

Sharing proptypes between components

Open andyearnshaw opened this issue 7 years ago • 4 comments

I have some common proptypes that I want to maintain in a single place as a constant:

export default const PROPTYPE_THEME = PropTypes.oneOf([
    'default', 'primary', 'white', 'blue', 'purple', 'pink', 'orange', 'green', 'red'
]);

If I add more themes, I only need to edit this one file and not every component. However, I can no longer change it in BlueKit, because it's detected as a "custom" property. It would be handy if BlueKit could either:

  • Trace the variable back to its declaration (through imports) to see if it's a PropType declaration; or
  • Add a codeblock for modifying "custom" PropTypes.

andyearnshaw avatar Mar 24 '17 10:03 andyearnshaw

Option 1 requires an improvement in react-docgen: https://github.com/reactjs/react-docgen/issues/33. Option 2 may still be doable.

andyearnshaw avatar Mar 24 '17 12:03 andyearnshaw

+1

alexcastillo avatar May 08 '17 17:05 alexcastillo

:+1:

pasupuletics avatar May 26 '17 09:05 pasupuletics

+1 just got surprised this, was sad it doesn't work since you can get similar enforcement with typescript

chris-allnutt avatar Feb 02 '18 16:02 chris-allnutt