-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: error boundary #8
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ const PluginContainerIframe = ({ | |
scrolling={scrolling} | ||
referrerPolicy="origin" // The sent referrer will be limited to the origin of the referring page: its scheme, host, and port. | ||
className={classNames( | ||
'border border-0', | ||
'border border-0 w-100', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sets the |
||
{ 'd-none': !ready }, | ||
className, | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,17 +21,14 @@ | |
*/ | ||
const { plugins, keepDefault } = usePluginSlot(id); | ||
|
||
const { fallback } = pluginProps; | ||
const { loadingFallback } = pluginProps; | ||
|
||
// TODO: Add internationalization to the "Loading" text on the spinner. | ||
let finalFallback = ( | ||
const defaultLoadingFallback = ( | ||
<div className={classNames(pluginProps.className, 'd-flex justify-content-center align-items-center')}> | ||
<Spinner animation="border" screenReaderText={intl.formatMessage(messages.loading)} /> | ||
</div> | ||
); | ||
if (fallback !== undefined) { | ||
finalFallback = fallback; | ||
} | ||
const finalLoadingFallback = loadingFallback !== undefined ? loadingFallback : defaultLoadingFallback; | ||
Comment on lines
+26
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now This is important to note when creating Plugin — perhaps a PluginWrapper component should be encouraged? Similar to what is used in the test files? This ensures that alerts, or any other fallback components for the Plugin, are wrapped and thus will fire the "ready" event which will clear the loading spinner and render whatever fallback is intended. Happy to elaborate more on this |
||
|
||
let finalChildren = []; | ||
if (plugins.length > 0) { | ||
|
@@ -43,7 +40,7 @@ | |
<PluginContainer | ||
key={pluginConfig.url} | ||
config={pluginConfig} | ||
fallback={finalFallback} | ||
fallback={finalLoadingFallback} | ||
{...pluginProps} | ||
/>, | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the
errorFallBackProp
toErrorFallbackComponent
. It is now capitalized to signify that it is a React component. The reason why I wanted to make this clear is because the<ErrorBoundary />
component fromfrontend-platform
wouldn't render anything unless it was provided as a React Component (ie.<ErrorFallback />
). It was picking up on the prop but wasn't rendering it to the page unless it was provided this way.