import React from 'react'
import { createBottomTabNavigator } from 'react-navigation'
import { View, Text } from 'react-native'
class Home extends React.Component {
componentDidMount() {
this.subs = [
this.props.navigation.addListener('didFocus', () => this._onFocus())
]
}
componentWillUnmount() {
this.subs.forEach(sub => sub.remove())
}
_onFocus = () => {
console.log('home on focus')
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Home!</Text>
</View>
)
}
}
class Test extends React.Component {
componentDidMount() {
this.subs = [
this.props.navigation.addListener('didFocus', () => this._onFocus())
]
}
componentWillUnmount() {
this.subs.forEach(sub => sub.remove())
}
_onFocus = () => {
console.log('test on focus')
}
render() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Test!</Text>
</View>
)
}
}
export default createBottomTabNavigator(
{
Home,
Test
}
)