fix(iOS) pushing a removing screen to controller#2766
fix(iOS) pushing a removing screen to controller#2766wvq wants to merge 1 commit intosoftware-mansion:mainfrom
Conversation
kkafar
left a comment
There was a problem hiding this comment.
Hey, that looks great, thanks. I'll test that when I have a moment & we'll see how do we proceed here.
|
@kkafar This fix conflicts with |
|
@wvq So do I understand correctly that, to fix the issue, changes in react-navigation are needed rather than in react-native-screens? If so, are you planning to do a PR there? I would love to see this fixed. 😄 |
|
@JustJoostNL No, the bug is on this project, I just can't find a proper way to mark the expired screen. |
|
Ah right. I guess someone has to come up with a global working solution then. |
|
For now, my temporary solution is run hook after npm install. #!/bin/bash
#
# temporary fix react-native-screens
#
# https://github.com/software-mansion/react-native-screens/issues/2559
#
check='disappeared'
screen_header='./node_modules/react-native-screens/ios/RNSScreen.h'
screen_mm='./node_modules/react-native-screens/ios/RNSScreen.mm'
screen_stack_mm='./node_modules/react-native-screens/ios/RNSScreenStack.mm'
if ! grep -qw $check $screen_header; then
sed -i '' '43i\
@property (nonatomic, readonly) BOOL disappeared;\
' $screen_header
fi
if ! grep -qw '_disappeared' $screen_mm; then
sed -i '' '1353i\
_disappeared = NO;\
' $screen_mm
sed -i '' '1365i\
_disappeared = NO;\
' $screen_mm
sed -i '' '1393i\
_disappeared = NO;\
' $screen_mm
sed -i '' '1431i\
_disappeared = NO;\
' $screen_mm
sed -i '' '1448i\
_disappeared = YES;\
' $screen_mm
fi
if ! grep -qw $check $screen_stack_mm; then
sed -i '' '680i\
if(!((RNSScreen *)top).disappeared) {\
' $screen_stack_mm
sed -i '' '682i\
}\
' $screen_stack_mm
fi
echo 'hook finished' |
|
This bug is caused by asynchrony, I think some logic may need to be refactored, which is not something that a simple solution can handle. |
Description
Fixes #2559
Bug track:
The logic waiting for the transition complete and then call
updateContainerhas problem.An old screen may be about to be removed but has not yet been removed.
which not in _controllers, but _reactSubviews not remove it yet.
updateContaineriterates _reactSubviews and callsetPushViewControllers.The old screen will push again.
This change add a property
disappearedto RNSScreen, defaults toNO.viewWillAppear/viewDidAppear/viewWillDisappearsetNOviewDidDisappearsetYESIn
RNSScreenStack'ssetPushViewControllers, check if it's not an new screen.