Last active
March 25, 2025 14:58
-
-
Save smontlouis/25262aae77c6fd871cbb7d8233e74f03 to your computer and use it in GitHub Desktop.
Expo DOM issue
This file contains hidden or 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/src/dom/dom-entry.tsx b/src/dom/dom-entry.tsx | |
index 43a920aa9d1ec3457b070aeaa9adcfbca844614d..c39c3bc0d94f85a3c2b9effd9b8179c5caadb7a7 100644 | |
--- a/src/dom/dom-entry.tsx | |
+++ b/src/dom/dom-entry.tsx | |
@@ -57,11 +57,6 @@ export function registerDOMComponent(AppModule: any) { | |
function DOMComponentRoot(props) { | |
// Props listeners | |
const [marshalledProps, setProps] = React.useState(() => { | |
- if (typeof window.$$EXPO_INITIAL_PROPS === 'undefined') { | |
- throw new Error( | |
- 'Initial props are not defined. This is a bug in the DOM Component runtime.' | |
- ); | |
- } | |
return window.$$EXPO_INITIAL_PROPS; | |
}); | |
@@ -86,6 +81,10 @@ export function registerDOMComponent(AppModule: any) { | |
); | |
}, [marshalledProps?.names]); | |
+ if (!marshalledProps) { | |
+ return null; | |
+ } | |
+ | |
return <AppModule {...props} {...(marshalledProps.props || {})} {...proxyActions} />; | |
} | |
diff --git a/src/dom/webview-wrapper.tsx b/src/dom/webview-wrapper.tsx | |
index 3ee2761fd9070c770ecb53ef4ade67ba7dac524d..568f06c0a4de52483117fb355334986a42ba83ca 100644 | |
--- a/src/dom/webview-wrapper.tsx | |
+++ b/src/dom/webview-wrapper.tsx | |
@@ -117,15 +117,24 @@ const RawWebView = React.forwardRef<object, Props>(({ dom, filePath, ...marshalP | |
...dom, | |
containerStyle: [containerStyle, debugZeroHeightStyle, dom?.containerStyle], | |
onLayout: __DEV__ ? debugOnLayout : dom?.onLayout, | |
+ onLoad: () => { | |
+ emit({ type: '$$props', data: smartActions }) | |
+ }, | |
injectedJavaScriptBeforeContentLoaded: [ | |
// On first mount, inject `$$EXPO_INITIAL_PROPS` with the initial props. | |
`window.$$EXPO_INITIAL_PROPS = ${JSON.stringify(smartActions)};true;`, | |
- dom?.matchContents ? getInjectBodySizeObserverScript() : null, | |
dom?.injectedJavaScriptBeforeContentLoaded, | |
'true;', | |
] | |
.filter(Boolean) | |
.join('\n'), | |
+ injectedJavaScript: [ | |
+ dom?.matchContents ? getInjectBodySizeObserverScript() : null, | |
+ dom?.injectedJavaScript, | |
+ 'true;', | |
+ ] | |
+ .filter(Boolean) | |
+ .join('\n'), | |
ref: webviewRef, | |
source, | |
style: [ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment