Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How to type props in styled-components react-native component?

$
0
0

How can I use the Props interface to type my react native Text component props with styled components? When I do it like this I don't get any props typing.

interface Props {  variant: TypeScaleVariant;  color: ContentColor;}const Typography = styled.Text<Props>`  font-weight: ${(props) => props.theme.typescale[props.variant].fontWeight};  font-size: ${(props) => props.theme.typescale[props.variant].fontSize};  line-height: ${(props) => props.theme.typescale[props.variant].lineHeight};  letter-spacing: ${(props) =>    props.theme.typescale[props.variant].letterSpacing};  color: ${(props) => props.theme.color[props.color]};`;Typography.defaultProps = { variant: 'bodyMedium', color: 'onSurface' };export default Typography;

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>