diff --git a/docs/Reference.md b/docs/Reference.md index 7d3752f..9257aca 100644 --- a/docs/Reference.md +++ b/docs/Reference.md @@ -102,7 +102,7 @@ Controls whether to adjust the content inset for web views that are placed behin ### `injectedJavaScript` -Set this to provide JavaScript that will be injected into the web page when the view loads. +Set this to provide JavaScript that will be injected into the web page when the view loads. Make sure the string evaluates to a valid type (`true` works) and doesn't otherwise throw an exception. | Type | Required | | ------ | -------- | diff --git a/ios/RNCWKWebView.m b/ios/RNCWKWebView.m index 95ce13c..f386051 100644 --- a/ios/RNCWKWebView.m +++ b/ios/RNCWKWebView.m @@ -512,8 +512,12 @@ static NSString *const MessageHanderName = @"ReactNative"; thenCall: (void (^)(NSString*)) callback { [self.webView evaluateJavaScript: js completionHandler: ^(id result, NSError *error) { - if (error == nil && callback != nil) { - callback([NSString stringWithFormat:@"%@", result]); + if (error == nil) { + if (callback != nil) { + callback([NSString stringWithFormat:@"%@", result]); + } + } else { + RCTLogError(@"Error evaluating injectedJavaScript: This is possibly due to an unsupported return type. Try adding true to the end of your injectedJavaScript string."); } }]; }