Skip to content

Commit 41576ca

Browse files
vahagnniVahagn Nikoghosyan
andauthored
fix(macOS): address regression due to didMoveToSuperview (react-native-webview#3006)
Co-authored-by: Vahagn Nikoghosyan <vahagnn@meta.com>
1 parent 4a7e7cd commit 41576ca

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

apple/RNCWebViewImpl.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,16 @@ - (WKWebViewConfiguration *)setUpWkWebViewConfig
436436
return wkWebViewConfig;
437437
}
438438

439+
// react-native-mac os does not support didMoveToSuperView https://github.com/microsoft/react-native-macos/blob/main/React/Base/RCTUIKit.h#L388
440+
#if !TARGET_OS_OSX
439441
- (void)didMoveToSuperview
440442
{
441443
if (_webView == nil) {
444+
#else
445+
- (void)didMoveToWindow
446+
{
447+
if (self.window != nil && _webView == nil) {
448+
#endif // !TARGET_OS_OSX
442449
WKWebViewConfiguration *wkWebViewConfig = [self setUpWkWebViewConfig];
443450
_webView = [[RNCWKWebView alloc] initWithFrame:self.bounds configuration: wkWebViewConfig];
444451
[self setBackgroundColor: _savedBackgroundColor];

0 commit comments

Comments
 (0)