ContributionBoundary

Organism

Error boundary for one contribution (a slot item, tab, widget or block): when it throws, only it is replaced by `fallback` (a node or `({ error, reset }) => node`, nothing by default) and its host keeps working. `onError(error, info)` reports; `resetKeys` resets when any value changes.

Admin: placeholder with retry

Preview

Contact: Jane Doe

Call log: 3 missed calls today.

The host keeps rendering whatever the contribution does.

Code
<ContributionBoundary
  onError={(error) => report(error)}
  fallback={({ reset }) => (
    <UnavailableContribution reason="failed" size="node" title="Call log" action={{ label: 'Retry', onClick: reset }} />
  )}
>
  <CallLog contactId={id} />
</ContributionBoundary>

End user: nothing

Preview

Contact: Jane Doe

Call log: 3 missed calls today.

The host keeps rendering whatever the contribution does.

Code
// No fallback: a broken contribution simply disappears for end users.
<ContributionBoundary onError={(error) => report(error)}>
  <CallLog contactId={id} />
</ContributionBoundary>
Sourcemodules/ui/ContributionBoundary.tsx