react-native-screens
react-native-screens copied to clipboard
feat(iOS, Stack): Migrate to new invalidate method
Description
This PR updates the logic responsible for triggering the invalidate callback. We're now aligning the logic to use RCTComponentViewProtocol callback, when available.
Depending on the React Native architecture and version, the invalidate mechanism behaves differently:
- Paper - the
invalidateflow continues to use theRCTInvalidatingprotocol. - Fabric, RN < 0.82.0 - scanning the list of mutations
- Fabric, RN starting from 0.82.0 - the recommended way to handle invalidation is through the callback provided by
RCTComponentViewProtocol. This PR enables usage of that callback.
Note: I'm using some common code from: https://github.com/software-mansion/react-native-screens/pull/3367
Changes
- added
RNSReactNativeVersionUtilsin stack - for runtime checks as the commit with the new method in protocol was CP to 0.82 release - merged invalidation paths in a single function
invalidateImpl
Test code and steps to reproduce
Check any example with native stack and verify whether invalidate callback is called from a proper path, e.g. by hitting a breakpoint.
Checklist
- [x] Included code example that can be used to test this change
- [x] Ensured that CI passes
Switching to draft until we drop support for RN versions before 0.82