Skip to content

Commit

Permalink
NavigatorIOS - Remove NavigationContext
Browse files Browse the repository at this point in the history
Reviewed By: fkgozali

Differential Revision: D4774022

fbshipit-source-id: 0184bcbcf6a458eac6377cc6e1cffc0924f0d2d2
  • Loading branch information
Eric Vicenti authored and facebook-github-bot committed Mar 27, 2017
1 parent af34c34 commit 7aa2c9a
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Libraries/Components/Navigation/NavigatorIOS.ios.js
Expand Up @@ -13,7 +13,6 @@

var EventEmitter = require('EventEmitter');
var Image = require('Image');
var NavigationContext = require('NavigationContext');
var RCTNavigatorManager = require('NativeModules').NavigatorManager;
var React = require('React');
var ReactNative = require('ReactNative');
Expand Down Expand Up @@ -499,7 +498,6 @@ var NavigatorIOS = React.createClass({
},

navigator: (undefined: ?Object),
navigationContext: new NavigationContext(),

componentWillMount: function() {
// Precompute a pack of callbacks that's frequently generated and passed to
Expand All @@ -515,19 +513,14 @@ var NavigatorIOS = React.createClass({
resetTo: this.resetTo,
popToRoute: this.popToRoute,
popToTop: this.popToTop,
navigationContext: this.navigationContext,
};
this._emitWillFocus(this.state.routeStack[this.state.observedTopOfStack]);
},

componentDidMount: function() {
this._emitDidFocus(this.state.routeStack[this.state.observedTopOfStack]);
this._enableTVEventHandler();
},

componentWillUnmount: function() {
this.navigationContext.dispose();
this.navigationContext = new NavigationContext();
this._disableTVEventHandler();
},

Expand Down Expand Up @@ -608,7 +601,6 @@ var NavigatorIOS = React.createClass({

_handleNavigatorStackChanged: function(e: Event) {
var newObservedTopOfStack = e.nativeEvent.stackLength - 1;
this._emitDidFocus(this.state.routeStack[newObservedTopOfStack]);

invariant(
newObservedTopOfStack <= this.state.requestedTopOfStack,
Expand Down Expand Up @@ -661,14 +653,6 @@ var NavigatorIOS = React.createClass({
});
},

_emitDidFocus: function(route: Route) {
this.navigationContext.emit('didfocus', {route: route});
},

_emitWillFocus: function(route: Route) {
this.navigationContext.emit('willfocus', {route: route});
},

/**
* Navigate forward to a new route.
* @param route The new route to navigate to.
Expand All @@ -678,7 +662,6 @@ var NavigatorIOS = React.createClass({
// Make sure all previous requests are caught up first. Otherwise reject.
if (this.state.requestedTopOfStack === this.state.observedTopOfStack) {
this._tryLockNavigator(() => {
this._emitWillFocus(route);

var nextStack = this.state.routeStack.concat([route]);
var nextIDStack = this.state.idStack.concat([getuid()]);
Expand Down Expand Up @@ -709,7 +692,6 @@ var NavigatorIOS = React.createClass({
this._tryLockNavigator(() => {
var newRequestedTopOfStack = this.state.requestedTopOfStack - n;
invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0');
this._emitWillFocus(this.state.routeStack[newRequestedTopOfStack]);
this.setState({
requestedTopOfStack: newRequestedTopOfStack,
makingNavigatorRequest: true,
Expand Down Expand Up @@ -758,8 +740,6 @@ var NavigatorIOS = React.createClass({
updatingAllIndicesAtOrBeyond: index,
});

this._emitWillFocus(route);
this._emitDidFocus(route);
},

/**
Expand Down

5 comments on commit 7aa2c9a

@gre
Copy link
Contributor

@gre gre commented on 7aa2c9a May 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of my code was relying on observing the WillFocus and DidFocus event, it's no longer possible?

@rossmartin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericvicenti why was this removed?

@AnyGong
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericvicenti I do not know how to upgrade my part of the relevant code, have better suggestions or ideas? Thank you very much

@ericvicenti
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use the old version of this JS file, you should be able to copy it into your project, use it directly, and change it however you'd like.

@rossmartin
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericvicenti Thanks for the update. I moved to react-navigation but this will probably help others.

Please sign in to comment.