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

How to solve ViewStyle typescript error in react native?

$
0
0

I'm trying to pass width parameter into StyleSheet like this :

<View style={styles.children(width)}>{children}</View>

And use it like this :

const styles = StyleSheet.create({  modalContent: {    flex: 1,    justifyContent: 'center',    margin: '5%',  },  modalOverlay: {    position: 'absolute',    top: 0,    bottom: 0,    left: 0,    right: 0,    backgroundColor: 'rgba(0,0,0,0.5)',  },  children: (width: any) => ({    width: width,    backgroundColor: 'white',    position: 'absolute',    bottom: 0,    borderTopRightRadius: 40,    borderTopLeftRadius: 40,    paddingVertical: 30,    paddingHorizontal: 20,  }),});,

But typescript throws an error This expression is not callable. No constituent of type 'ViewStyle | TextStyle | ImageStyle' is callable.

screenshot

How can I solve this typescript problem ?


Viewing all articles
Browse latest Browse all 6287

Trending Articles



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