mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: instantiating multiple `RCTAppDependencyProvider` instances creates problems with their internal state, because the internal fields such as [`_thirdPartyFabricComponents` are populated once](https://github.com/facebook/react-native/blob/f5feb73022f9340583ebcf576eaedd3ca5677e1a/packages/react-native/scripts/codegen/templates/RCTAppDependencyProviderMM.template#L60) for the entire app (see [`dispatch_once`](https://developer.apple.com/documentation/dispatch/1447169-dispatch_once)). That means when you create 2 instances, and call `thirdPartyFabricComponents` on them, the first instance will respond with a dictionary and the second with `nil`. This is unexpected. ## Changelog: [IOS] [FIXED] - enable use of multiple `RCTAppDependencyProvider` instances Pull Request resolved: https://github.com/facebook/react-native/pull/49889 Test Plan: `rnTester` - the templates are used by codegen. Running `pod install`, the files were generated correctly from the `.template` files. I was able to verify that accessing `thirdPartyFabricComponents` on multiple instances of `RCTAppDependencyProvider` returns valid result. <details> <summary>screenshot</summary> <img width="789" alt="Screenshot 2025-03-07 at 15 11 22" src="https://github.com/user-attachments/assets/9270ba90-ae7f-491a-a53a-f7e1f4606438" /> </details> Reviewed By: javache Differential Revision: D70892779 Pulled By: cipolleschi fbshipit-source-id: 27c7c8fd9982b6427daec02e0de59b08ad20bfad