Skip to content

Commit 712abe5

Browse files
committed
Prevent running react native polyfill multiple times
1 parent 4c2c4f5 commit 712abe5

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.changeset/three-ants-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plextv/react-native-lightning": patch
3+
---
4+
5+
Prevent running react native polyfill multiple times

packages/react-native-lightning/src/plugins/reactNativePolyfillsPlugin.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ function tryFindFocusManager(
4444
export const reactNativePolyfillsPlugin = (): Plugin => {
4545
// Track the single FocusManager instance
4646
let focusManager: FocusManager<LightningViewElement> | null = null;
47+
let polyfilled = false;
4748

4849
return {
4950
async init() {
51+
if (polyfilled) {
52+
return;
53+
}
54+
5055
const originalSetProps = LightningViewElement.prototype.setProps;
5156

5257
const nativeMethods = {
@@ -147,6 +152,8 @@ export const reactNativePolyfillsPlugin = (): Plugin => {
147152
return acc;
148153
}, {} as PropertyDescriptorMap),
149154
);
155+
156+
polyfilled = true;
150157
},
151158

152159
onCreateInstance(instance) {

0 commit comments

Comments
 (0)