Skip to content

Commit

Permalink
fix(react): lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilar committed Feb 4, 2021
1 parent 977ce2e commit e5780f4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/drivers/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type ReactLibraryType = {|
/**
* Util to check if component is currently mounted
*/
function isMounted(component, ReactDOM) {
function isMounted(component, ReactDOM) : boolean {
try {
return !!ReactDOM.findDOMNode(component);
return Boolean(ReactDOM.findDOMNode(component));
}
catch (error) {
// Error: Unable to find node on an unmounted component
Expand All @@ -63,14 +63,14 @@ export const react : ComponentDriverType<*, ReactLibraryType, typeof ReactClassT
parent.render(el, CONTEXT.IFRAME)
.catch(error => {
// component failed to render, possibly because it was closed or destroyed.
if(!isMounted(this, ReactDOM)) {
if (!isMounted(this, ReactDOM)) {
// not mounted anymore, we can safely ignore the error
return
return;
}
// still mounted, throw error inside react to allow a parent component or ErrorBoundary to handle it
this.setState(() => {
throw error
})
throw error;
});
});
this.setState({ parent });
}
Expand Down

0 comments on commit e5780f4

Please sign in to comment.