【发布时间】:2017-10-23 10:31:42
【问题描述】:
我是 react-native 的新手,试图创建自己的组件,但它一直显示一个空白屏幕。
这是我的组件代码
class BoxComponent extends Component {
constructor(props){
super(props);
this.state = {message: null}
}
componentMounted(){
axios.get('example.com').then(response => {
this.setState({
message: response.data
})
})
}
render(){
return (<Text style={style.boxStyle}>{this.state.message}</Text>)
}
}
【问题讨论】:
-
componentMounted()?你的意思是componentDidMount()?
标签: android ios react-native