|  | @@ -9,6 +9,7 @@
 | 
	
		
			
			| 9 | 9 |  #import "React/RCTUIManager.h"
 | 
	
		
			
			| 10 | 10 |  #import "RNNErrorHandler.h"
 | 
	
		
			
			| 11 | 11 |  #import "RNNDefaultOptionsHelper.h"
 | 
	
		
			
			|  | 12 | +#import "UIViewController+RNNOptions.h"
 | 
	
		
			
			| 12 | 13 |  
 | 
	
		
			
			| 13 | 14 |  static NSString* const setRoot	= @"setRoot";
 | 
	
		
			
			| 14 | 15 |  static NSString* const setStackRoot	= @"setStackRoot";
 | 
	
	
		
			
			|  | @@ -188,9 +189,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
 | 
	
		
			
			| 188 | 189 |  		[_store removeComponent:componentId];
 | 
	
		
			
			| 189 | 190 |  		[_eventEmitter sendOnNavigationCommandCompletion:pop params:@{@"componentId": componentId}];
 | 
	
		
			
			| 190 | 191 |  		completion();
 | 
	
		
			
			| 191 |  | -	} rejection:^(NSString *code, NSString *message, NSError *error) {
 | 
	
		
			
			| 192 |  | -		
 | 
	
		
			
			| 193 |  | -	}];
 | 
	
		
			
			|  | 192 | +	} rejection:rejection];
 | 
	
		
			
			| 194 | 193 |  }
 | 
	
		
			
			| 195 | 194 |  
 | 
	
		
			
			| 196 | 195 |  - (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
 | 
	
	
		
			
			|  | @@ -240,19 +239,26 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
 | 
	
		
			
			| 240 | 239 |  	}];
 | 
	
		
			
			| 241 | 240 |  }
 | 
	
		
			
			| 242 | 241 |  
 | 
	
		
			
			| 243 |  | -- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion {
 | 
	
		
			
			|  | 242 | +- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
 | 
	
		
			
			| 244 | 243 |  	[self assertReady];
 | 
	
		
			
			| 245 | 244 |  	
 | 
	
		
			
			| 246 |  | -	[CATransaction begin];
 | 
	
		
			
			| 247 |  | -	[CATransaction setCompletionBlock:^{
 | 
	
		
			
			| 248 |  | -		[_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
 | 
	
		
			
			| 249 |  | -	}];
 | 
	
		
			
			| 250 | 245 |  	UIViewController<RNNParentProtocol> *modalToDismiss = (UIViewController<RNNParentProtocol>*)[_store findComponentForId:componentId];
 | 
	
		
			
			|  | 246 | +	
 | 
	
		
			
			|  | 247 | +	if (!modalToDismiss.isModal) {
 | 
	
		
			
			|  | 248 | +		[RNNErrorHandler reject:reject withErrorCode:1013 errorDescription:@"component is not a modal"];
 | 
	
		
			
			|  | 249 | +		return;
 | 
	
		
			
			|  | 250 | +	}
 | 
	
		
			
			|  | 251 | +	
 | 
	
		
			
			| 251 | 252 |  	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
 | 
	
		
			
			| 252 | 253 |  	[modalToDismiss.getCurrentChild.options overrideOptions:options];
 | 
	
		
			
			| 253 | 254 |  	
 | 
	
		
			
			| 254 | 255 |  	[self removePopedViewControllers:modalToDismiss.navigationController.viewControllers];
 | 
	
		
			
			| 255 | 256 |  	
 | 
	
		
			
			|  | 257 | +	[CATransaction begin];
 | 
	
		
			
			|  | 258 | +	[CATransaction setCompletionBlock:^{
 | 
	
		
			
			|  | 259 | +		[_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
 | 
	
		
			
			|  | 260 | +	}];
 | 
	
		
			
			|  | 261 | +	
 | 
	
		
			
			| 256 | 262 |  	[_modalManager dismissModal:modalToDismiss completion:completion];
 | 
	
		
			
			| 257 | 263 |  	
 | 
	
		
			
			| 258 | 264 |  	[CATransaction commit];
 |