I am resetting the current view with this code
NavigationActions.reset({ index: 0, key: null, actions: [ NavigationActions.navigate({ routeName: 'Login' }) ] });
Some times it works and some time I get a Signal Sigabrt
error on the RCTUIManager.m
file in Xcode. I can't figure out when did the problem occur. The error happens in this function
- (void)setSize:(CGSize)size forView:(UIView *)view
{
RCTAssertMainQueue();
NSNumber *reactTag = view.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{
RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag];
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag); // ERROR in this line
if (CGSizeEqualToSize(size, shadowView.size)) {
return;
}
shadowView.size = size;
[self setNeedsLayout];
});
}
If I delete the code on the function every thing works fine. When there is no crashes, the console is always printing a warning
View #1430 of type RCTView has a shadow set but cannot calculate shadow efficiently. Consider setting a background color to fix this, or apply the shadow to a more specific component.
But I do not have any View using shadow and could not figure out which react-native element is doing it.
Edit: if I check that shadowView is not null everything works fine
if(shadowView){
RCTAssert(shadowView != nil, @"Could not locate view with tag #%@", reactTag);
}
Is this a Bug in RN ?
The solution I found is to override the router's getStateForAction function and handle the reset.
So you could dispatch something like this:
NavigationActions.reset({ index: 0, key: null, actions: { navigateTo: 'Login' }});
And handle this case in a custom getStateForAction
function:
const defaultGetStateForAction = YourNavigator.router.getStateForAction
YourNavigator.router.getStateForAction = (action, state) => {
if (action.type === NavigationActions.RESET && action.actions.navigateTo) {
const updatedRoutes = [{routeName: action.actions.navigateTo}]
return {
...state,
routes: updatedRoutes,
index: 0
}
}
return defaultGetStateForAction(action, state)
}
Here you can read more about React Navigation - Custom Navigation Actions
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With