Waleed Arshad Waleed Arshad - 8 months ago 252
React JSX Question

Dynamic inilne style with default StyleSheet React Native

I need to give dynamic inline style with static default stylesheet style. How can I achieve this

style={[styles.card,{{width:width, height: height}}]}>
<View style={styles.card}>
source={{uri: this.props.media.image_url}}
style={{width:width, height: this.props.media.height}}/>

Above code is not working for me.


Nope, the problem isn't the order, you haven't passed the dynamic(inline styles) properly. You wrapped them in additional curly braces

Change this:

style={[styles.card,{{width:width,  height: height}}]}


style={[styles.card,{width:width,  height: height}]}

You have actually done the same thing in your answer above.