I'd like to reuse a common set of PropTypes across several components. Something like:
const textProps = {
/** Header text */
children: PropTypes.node.isRequired,
/** Weight of the text */
weight: PropTypes.oneOf(['thin', 'normal', 'semibold', 'bold']),
}
I've added this object to a file and am exporting it as a named export textProps
.
I then import it into a component file as:
import { textProps } from 'path/to/textProps'
And the component file uses styled-components
to define a component:
const H1 = styled.h1`
font-size: "50px"
`;
H1.propTypes = textProps;
The problem is the 'Props & Methods' section isn't displayed in the Styleguidist guide when textProps
is imported.
When I define textProps
within the H1
file it works as expected.
Is there a way to define a common set of PropTypes, import them into a component, and have them appear in the Styleguidist guide?