From 637ffb175db17af0582d503e9f510c4fe35c115b Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Wed, 28 Jun 2023 09:49:57 -0700 Subject: [PATCH] Fix setRuntimeConfigProvider multiple times error Summary: Fix the following error: {F1038388240} Calling ```setRuntimeConfigProvider``` multiple times is not always a wrong behaviour, the following could happen and before this diff App C will raise above error: - App A has main bundle X - App B has main bundle Y - App C has main bundle X and bundle Y To fix we guarantee ```setRuntimeConfigProvider``` only called once instead of raising an error. Changelog: [iOS][Changed] Fix setRuntimeConfigProvider called multiple times error Reviewed By: dmytrorykun Differential Revision: D47094267 fbshipit-source-id: c8473f4f7d639a73e0201c6d72781c01e6cf95fd --- .../Libraries/NativeComponent/NativeComponentRegistry.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js index 4ab3acd54ef4b6..ace5eb38e605cd 100644 --- a/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js +++ b/packages/react-native/Libraries/NativeComponent/NativeComponentRegistry.js @@ -38,11 +38,9 @@ export function setRuntimeConfigProvider( verify: boolean, }, ): void { - invariant( - getRuntimeConfig == null, - 'NativeComponentRegistry.setRuntimeConfigProvider() called more than once.', - ); - getRuntimeConfig = runtimeConfigProvider; + if (getRuntimeConfig === undefined) { + getRuntimeConfig = runtimeConfigProvider; + } } /**