Waleed Arshad Waleed Arshad - 1 year ago 444
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download