Created
March 27, 2022 17:19
-
-
Save lucasjohnston/5bf626fae923009ae1cf5a5db894842f to your computer and use it in GitHub Desktop.
react-native-portalize+1.0.7.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/react-native-portalize/lib/Host.js b/node_modules/react-native-portalize/lib/Host.js | |
index 98753cb..6d4f51b 100644 | |
--- a/node_modules/react-native-portalize/lib/Host.js | |
+++ b/node_modules/react-native-portalize/lib/Host.js | |
@@ -14,59 +14,62 @@ const Manager_1 = require("./Manager"); | |
exports.Context = React.createContext(null); | |
exports.Host = ({ children, style }) => { | |
const managerRef = React.useRef(null); | |
- const queue = []; | |
+ const queueRef = React.useRef([]); | |
const { generateKey, removeKey } = useKey_1.useKey(); | |
React.useEffect(() => { | |
- var _a, _b, _c; | |
- while (queue.length && managerRef.current) { | |
- const action = queue.pop(); | |
+ var _a, _b, _c, _d, _e; | |
+ while (((_a = queueRef.current) === null || _a === void 0 ? void 0 : _a.length) && managerRef.current) { | |
+ const action = (_b = queueRef.current) === null || _b === void 0 ? void 0 : _b.pop(); | |
if (action) { | |
switch (action.type) { | |
case 'mount': | |
- (_a = managerRef.current) === null || _a === void 0 ? void 0 : _a.mount(action.key, action.children); | |
+ (_c = managerRef.current) === null || _c === void 0 ? void 0 : _c.mount(action.key, action.children); | |
break; | |
case 'update': | |
- (_b = managerRef.current) === null || _b === void 0 ? void 0 : _b.update(action.key, action.children); | |
+ (_d = managerRef.current) === null || _d === void 0 ? void 0 : _d.update(action.key, action.children); | |
break; | |
case 'unmount': | |
- (_c = managerRef.current) === null || _c === void 0 ? void 0 : _c.unmount(action.key); | |
+ (_e = managerRef.current) === null || _e === void 0 ? void 0 : _e.unmount(action.key); | |
break; | |
} | |
} | |
} | |
}, []); | |
const mount = (children) => { | |
+ var _a; | |
const key = generateKey(); | |
if (managerRef.current) { | |
managerRef.current.mount(key, children); | |
} | |
else { | |
- queue.push({ type: 'mount', key, children }); | |
+ (_a = queueRef.current) === null || _a === void 0 ? void 0 : _a.push({ type: 'mount', key, children }); | |
} | |
return key; | |
}; | |
const update = (key, children) => { | |
+ var _a, _b; | |
if (managerRef.current) { | |
managerRef.current.update(key, children); | |
} | |
- else { | |
+ else if (queueRef.current) { | |
const op = { type: 'mount', key, children }; | |
- const index = queue.findIndex(o => o.type === 'mount' || (o.type === 'update' && o.key === key)); | |
+ const index = (_b = (_a = queueRef.current) === null || _a === void 0 ? void 0 : _a.findIndex(o => o.type === 'mount' || (o.type === 'update' && o.key === key))) !== null && _b !== void 0 ? _b : -1; | |
if (index > -1) { | |
- queue[index] = op; | |
+ queueRef.current[index] = op; | |
} | |
else { | |
- queue.push(op); | |
+ queueRef.current.push(op); | |
} | |
} | |
}; | |
const unmount = (key) => { | |
+ var _a; | |
if (managerRef.current) { | |
managerRef.current.unmount(key); | |
removeKey(key); | |
} | |
else { | |
- queue.push({ type: 'unmount', key }); | |
+ (_a = queueRef.current) === null || _a === void 0 ? void 0 : _a.push({ type: 'unmount', key }); | |
} | |
}; | |
return (React.createElement(exports.Context.Provider, { value: { mount, update, unmount } }, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment