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

User Gilsha
by
4.2k 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}]}/>

User Entalyan
by
3.8k points