mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-04-29 12:55:21 +08:00
Navigation Event Subscriptions (#3345)
* Add fbemitter, keep flow passing * Begin support for event emitter - Adds emitter to navigation prop - Emits top level onAction event - stub getChildEventSubscriber for child events * Support navigationState.isNavigating * Focus and blur events starting to work - Navigation completion action wired up - Event chaining logic built in getChildEventSubscriber - Renamed onAction evt to ‘action’ * Wrap up events progress and testing * Rename to isTransitioning and COMPLETE_TRANSITION * rm accidental dependency * Suppoert event payload type
This commit is contained in:
@@ -114,4 +114,35 @@ const SimpleTabs = TabNavigator(
|
||||
}
|
||||
);
|
||||
|
||||
export default SimpleTabs;
|
||||
class SimpleTabsContainer extends React.Component {
|
||||
static router = SimpleTabs.router;
|
||||
componentDidMount() {
|
||||
this._s0 = this.props.navigation.addListener('willFocus', this._onWF);
|
||||
this._s1 = this.props.navigation.addListener('didFocus', this._onDF);
|
||||
this._s2 = this.props.navigation.addListener('willBlur', this._onWB);
|
||||
this._s3 = this.props.navigation.addListener('didBlur', this._onDB);
|
||||
}
|
||||
componentWillUnmount() {
|
||||
this._s0.remove();
|
||||
this._s1.remove();
|
||||
this._s2.remove();
|
||||
this._s3.remove();
|
||||
}
|
||||
_onWF = a => {
|
||||
console.log('_onWillFocus tabsExample ', a);
|
||||
};
|
||||
_onDF = a => {
|
||||
console.log('_onDidFocus tabsExample ', a);
|
||||
};
|
||||
_onWB = a => {
|
||||
console.log('_onWillBlur tabsExample ', a);
|
||||
};
|
||||
_onDB = a => {
|
||||
console.log('_onDidBlur tabsExample ', a);
|
||||
};
|
||||
render() {
|
||||
return <SimpleTabs navigation={this.props.navigation} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default SimpleTabsContainer;
|
||||
|
||||
Reference in New Issue
Block a user