fix: backport iOS invalid element type crash fix

This commit is contained in:
PalmDevs 2024-12-05 19:15:52 +07:00
parent eb6b9bf607
commit afacfa0648
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -23,6 +23,12 @@ export function deleteJsxCreate(Component: string, callback: Callback) {
*/ */
export function patchJsx() { export function patchJsx() {
const callback = ([Component]: unknown[], ret: JSX.Element) => { const callback = ([Component]: unknown[], ret: JSX.Element) => {
// Band-aid fix for iOS invalid element type crashes
if (typeof ret.type === 'undefined') {
ret.type = 'RCTView'
return ret
}
// The check could be more complex, but this is fine for now to avoid overhead // The check could be more complex, but this is fine for now to avoid overhead
if (typeof Component === "function" && callbacks.has(Component.name)) { if (typeof Component === "function" && callbacks.has(Component.name)) {
const cbs = callbacks.get(Component.name)!; const cbs = callbacks.get(Component.name)!;