asked 74.2k views
2 votes
How to use a state value in stylesheet in react native.

asked
User Gilsha
by
8.3k points

1 Answer

3 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}]}/>

answered
User Entalyan
by
7.6k points