Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: disable showing errors in cells, you can turn on the old bhavio…
…r with shouldShowErrorInCells: false, (#1276) it will still log the error. this makes the occasional problems with slate less severe.
- Loading branch information
Showing
5 changed files
with
55 additions
and
31 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/editor/src/core/components/Cell/CellErrorGate.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
import ErrorCell from './ErrorCell'; | ||
|
||
export const CellErrorGate = class extends React.Component< | ||
{ | ||
children: React.ReactNode; | ||
nodeId: string; | ||
shouldShowError?: boolean; | ||
}, | ||
{ error: Error | null } | ||
> { | ||
state = { | ||
error: null, | ||
}; | ||
componentDidCatch(error: Error) { | ||
this.setState({ error }); | ||
console.error(error); | ||
} | ||
|
||
reset() { | ||
this.setState({ error: null }); | ||
} | ||
|
||
render() { | ||
if (this.state.error && this.props.shouldShowError) { | ||
return ( | ||
<ErrorCell | ||
nodeId={this.props.nodeId} | ||
error={this.state.error} | ||
resetError={this.reset.bind(this)} | ||
/> | ||
); | ||
} | ||
return this.props.children; | ||
} | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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