Add error boundary logic#210
Conversation
| const renderOutputs = useCallback(() => { | ||
| // Note: this approach is not ideal, but it ensures that if this component throws, we can put an error boundary that works | ||
| // Otherwise, just calling `<ErrorBoundary FallbackComponent={OutputsErrorBoundary}>renderOutputs()</ErrorBoundary>` will not work as expected | ||
| const MaybeOutputs = useCallback(() => { |
There was a problem hiding this comment.
If a component sometimes returns empty, I like to prefix them with Maybe . Normally, if we want to render a cell component, conditionally, we wouldn't do it inside the cell, and instead do something like this:
<div>{showCell && <Cell />}<div>But if the Cell component owns its own state, and sometimes returns null, we should name it MaybeCell .
That way, if you render it, you're not surprised if it's sometimes not showing up:
<div><MaybeCell /></div>This could also apply to nullable variables or types. Normally, you don't want null or undefined as part of a type, but when you do, it would be prefixed with "maybe".
| {hasOutputs && cell.outputVisible && renderOutputs()} | ||
| <ErrorBoundary FallbackComponent={OutputsErrorBoundary}> | ||
| {cell.outputVisible && <MaybeOutputs />} | ||
| </ErrorBoundary> |
There was a problem hiding this comment.
Might as well do this per output honestly. Sometimes the custom output types in notebooks have strangeness.
There was a problem hiding this comment.
I'll probably do it in another PR
|
Oops, merged individual commits too |
|
It all squashes anyways, no prob |
Uh oh!
There was an error while loading. Please reload this page.