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

React Native functions in Stylesheet typescript

$
0
0

I don't understand how to create a good interface dynamic stylesheet

interface Styles {  container: (backgroundColor: string) => StyleProp<ViewStyle>;  image: (color: string) => StyleProp<ImageStyle>;}const styles = StyleSheet.create<Styles>({  container: (backgroundColor: string) => ({    width: "100%,    height: "100%,    backgroundColor,  }),  image: (color: string) => ({    width: 10,    height: 10,    tintColor: color,  }),});

I got an error like this :

 Type '(backgroundColor: string) => StyleProp<ViewStyle>' is not assignable to type 'ViewStyle | ImageStyle | TextStyle'

Viewing all articles
Browse latest Browse all 6287

Trending Articles



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