Skip to content

Commit

Permalink
fix for \#878
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielZlotin committed Mar 20, 2017
1 parent 1438041 commit 73927dc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 12 deletions.
3 changes: 3 additions & 0 deletions ios/RNNCommandsHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ -(instancetype) initWithStore:(RNNStore*)store controllerFactory:(RNNControllerF

-(void) setRoot:(NSDictionary*)layout {
[self assertReady];

[_modalManager dismissAllModals];

UIViewController *vc = [_controllerFactory createLayoutAndSaveToStore:layout];

UIApplication.sharedApplication.delegate.window.rootViewController = vc;
Expand Down
2 changes: 1 addition & 1 deletion ios/RNNReactRootViewCreator.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ @interface RNNReactRootView : RCTRootView

@implementation RNNReactRootView

-(void) dealloc {
-(void)dealloc {

}

Expand Down
23 changes: 18 additions & 5 deletions ios/RNNRootViewController.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

#import "RNNRootViewController.h"
#import <React/RCTRootView.h>

@interface RNNRootViewController()
@property NSString* containerId;
Expand All @@ -17,19 +16,33 @@ -(instancetype)initWithNode:(RNNLayoutNode*)node rootViewCreator:(id<RNNRootView
self.eventEmitter = eventEmitter;

self.view = [creator createRootView:self.containerName rootViewId:self.containerId];

// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onJsReload) name:RCTJavaScriptWillStartLoadingNotification object:nil];

return self;
}

-(void)viewDidAppear:(BOOL)animated
{
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.eventEmitter sendContainerStart:self.containerId];
}

-(void)viewDidDisappear:(BOOL)animated
{
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
[self.eventEmitter sendContainerStop:self.containerId];
}

///**
// * fix for
// */
//-(void)onJsReload {
// [[NSNotificationCenter defaultCenter] removeObserver:self];
// [[NSNotificationCenter defaultCenter] removeObserver:self.view];
// self.view = nil;
//}

-(void)dealloc {

}

@end
1 change: 1 addition & 0 deletions ios/ReactNativeNavigation.m
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,5 @@ -(void)resetRootViewControllerOnlyOnJSDevReload {
}



@end
4 changes: 0 additions & 4 deletions playground/e2e/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ describe('reload app', () => {
it('show welcome screen after reload', () => {
expect(elementByLabel('React Native Navigation!')).toBeVisible();
});

it('show modal then reload will not cause a leak', () => {
elementByLabel('Show Modal').tap();
});
});

function elementByLabel(label) {
Expand Down
9 changes: 7 additions & 2 deletions playground/src/containers/ModalScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ class ModalScreen extends Component {
onClickDismissFirstInStack() {
Navigation.dismissModal(_.head(this.props.previousModalIds));
}

onClickDismissAllModals() {
Navigation.dismissAllModals();
// Navigation.dismissAllModals();
Navigation.setRoot({
container: {
name: 'navigation.playground.WelcomeScreen'
}
});
}

getModalPosition() {
Expand Down

0 comments on commit 73927dc

Please sign in to comment.