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

how can i get the right style props for the react-native styles?

$
0
0

When trying to get the appropriate styles for my react native app, it says that it does not work for the button styles.

How can I make the type error disappear?

interface TextButtonProps {  buttonStyle?: StyleProp<ViewStyle>;  labelStyle?: StyleProp<TextStyle>;  click: () => void;  text: string;}interface Styles {  button: ViewStyle;  icon: ImageStyle;  label: TextStyle;}const TextButton: React.SFC<TextButtonProps> = ({ buttonStyle, text, click }): JSX.Element => {  const styles = StyleSheet.create<Styles>({    button: buttonStyle,  });

error:

Type 'StyleProp<ViewStyle>' is not assignable to type 'ViewStyle | TextStyle | ImageStyle'.  Type 'undefined' is not assignable to type 'ViewStyle | TextStyle | ImageStyle'.ts(2322)TextButton.tsx(13, 3): The expected type comes from property 'button' which is declared here on type 'Styles | NamedStyles<Styles>'

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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