react-bluekit
react-bluekit copied to clipboard
Sharing proptypes between components
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.
Option 1 requires an improvement in react-docgen: https://github.com/reactjs/react-docgen/issues/33. Option 2 may still be doable.
+1
:+1:
+1 just got surprised this, was sad it doesn't work since you can get similar enforcement with typescript