Invalid URI prop doesn't trigger onError or renderError callbacks
See original GitHub issueBug description:
Providing an invalid source.uri
prop does not result in renderError
or onError
being executed. Instead the WebView remains in the loading state and a console.warn
for an unhandled promise rejection is displayed.
To Reproduce:
Use test
as your uri prop.
<WebView
source={{ uri: 'test' }}
onError={syntheticEvent => {
const { nativeEvent } = syntheticEvent;
console.warn('WebView error: ', nativeEvent);
}}
renderError={errorName => <Error name={errorName} />}
/>
Expected behavior:
Either onError
or renderError
should be executed.
Screenshots/Videos:
Environment:
- OS: macOS Mojave
- OS version: 10.14.4
- react-native version: 0.57.8
- react-native-webview version: 5.6.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:8
- Comments:20
Top Results From Across the Web
react.js Replace img src onerror
I am trying to replace the image with a default image if the image does not exist and there is a 404 error....
Read more >React Error Handling And Reporting With Error Boundary ...
In this article, we'll explore the concept of error boundaries in a React application. We'll work through an example app to see how...
Read more >Error Handling in React 16 – React Blog
Introducing Error Boundaries To solve this problem for React users, React 16 introduces a new concept of an “error boundary”. Error boundaries ...
Read more >DataSearch - Reactive Manual
Props · componentId String unique identifier of the component, can be referenced in other components' react prop. · dataField String or Array database...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
unable to open url
error message comes directly fromreact-native
linking, for iOS at least.As @mikehardy pointed out It looks like RN Webview tries to open urls that don’t match the originWhiteList in an external browser. Currently the
createOnShouldStartLoadWithRequest
function doesn’t have any error handler callback passed to it. Seems simple enough to add ahandleInvalidUrl
callback. May need to submit a PR to fix… unless someone beats me to it 😁UPDATE - looked into trying to patch this, but the
onError
callback prop expects a SyntheticEvent. Not sure how to pull that off without diving more into native code. Not worth the effort at this point as theconsole.warn
is already providing visibility to the error msg.As a workaround I just added a 10s timeout that will manually trigger the error screen. UX is okay but not optimal.
This shouldn’t be closed, it’s still an issue. If you try to load some invalid URL there appears to be no way to avoid the promise rejection warning ?
My test case is to attempt to open a deep-link on a device that can’t handle it. Popular style to try, facebook: url could be ‘fb://page/225517294919485’ and if you don’t have facebook app installed you’ll get
Duplicate #1209 (also closed stale, no resolution though)