113,031 views
7 votes
7 votes
How to use a state value in stylesheet in react native.

User Maxbublis
by
2.9k points

1 Answer

26 votes
26 votes

Answer:

Change this code:

return <View style={[styles.container, backgroundColor: this.state.bg]}/>

for this code:

return <View style={[styles.container, {backgroundColor: this.state.bg}]}/>

User Derdc
by
3.3k points