【发布时间】:2019-12-16 01:36:57
【问题描述】:
我有一个 react native 组件,它包含 WillFocus 和 componentDidMount 函数。 我的问题是,如果我导航到该组件,首先触发哪个功能? 'WillFocus' 或 'componentDidMount' 示例代码如下所示
class Notifications extends Component {
static navigationOptions = {
header: null
}
constructor(props) {
super(props);
const{navigation}=this.props
this.state = {
highlightHome : true,
highlightNotifications: true,
}
}
willFocus = [this.props.navigation.addListener(
'willFocus',
payload => {
console.log('willFocus')
}
)]
componentDidMount() {
console.log('componentDidMount')
}
}
【问题讨论】:
标签: javascript react-native components jsx