我正在尝试根据状态设置容器的背景,但它不断向我显示未定义错误bg
constructor(props) {
super(props)
this.state = {
bg:'#fff'
}
}
render(){
return(<View style={styles.container} />)
}
const styles = StyleSheet.create({
container:{
flex: 1,
backgroundColor: this.state.bg,
}
})
Run Code Online (Sandbox Code Playgroud) react-native ×1