mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 01:25:39 +00:00
0a875790f5
of the navigator component. Summary: Per offline discussion with @evv, we'd like to deprecate the `onDidFocus` and `onWillFocus` API that makes it really hard for the descendent children of a navigator to observe its focus change events. @public Since for now the descendent children do have access to the navigator via `this.props.navigator`, this diff makes it easy to observe the focus change event by doing: ``` this.props.navigator.addListener('willfocus', this._onFocus); ``` The goal is to make the event system in navigator more useful and maintainable. Test Plan: Test Video: https://www.facebook.com/pxlcld/mrzS 1. jest: ./Libraries/FBReactKit/js/runTests.js NavigationEventEmitter 2. Load UI Explorer: <Navigator />, see console logs that shows the focus change events fires.
22 lines
367 B
JavaScript
22 lines
367 B
JavaScript
/**
|
|
* Copyright 2004-present Facebook. All Rights Reserved.
|
|
*
|
|
* @providesModule NavigationEvent
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
class NavigationEvent {
|
|
type: String;
|
|
target: Object;
|
|
data: any;
|
|
|
|
constructor(type: String, target: Object, data: any) {
|
|
this.type = type;
|
|
this.target = target;
|
|
this.data = data;
|
|
}
|
|
}
|
|
|
|
module.exports = NavigationEvent;
|