I recently found a way to set default props on React components, like this:
type Props = { children: any, color?: keyof typeof textColors,};const GTitle: React.FC<Props> = ({ children, color }) => (<Title color={textColors[color]}> {children}</Title>);GTitle.defaultProps = { color: 'primary',};
The problem is that even if I define that there is a default property, the TypeScript keeps accusing the possibility of having an undefined value, as in the example below: