我有这种格式的代码:
const Test = React.createClass({
tabIcons: [],
propTypes: {
...
},
render() {
return
<View> ...</View>
}
})
我不确定如何将tabIcons转换为新格式
class Test extends Component {
static propTypes = {
...
}
render () {
return (
<View> ...</View>
)
}
}
答案 0 :(得分:0)
您可以在构造函数中添加tabIcons
作为类属性。
class Test extends Component {
constructor(){
this.tabIcons = [];
}
static propTypes = {
...
}
render () {
return (
<View> ...</View>
)
}
}
现在,您可以在类似州的任何地方访问它。
this.tabIcons.push(newItem)