Fix crash with ModalError
## Issue There was one instance of ModalError that wasn't wrapped in the Suspense. ## Fix - Moved `getModal` outside to make the code cleaner. Due to the length of `getModal`, I didn't notice the early return statement. - Fix ModalError's Suspense.
This commit is contained in:
parent
bf0aac2339
commit
3d1d448afb
1 changed files with 98 additions and 94 deletions
|
@ -97,29 +97,6 @@ const ModalYoutubeWelcome = lazyImport(() =>
|
||||||
import('modal/modalYoutubeWelcome' /* webpackChunkName: "modalYoutubeWelcome" */)
|
import('modal/modalYoutubeWelcome' /* webpackChunkName: "modalYoutubeWelcome" */)
|
||||||
);
|
);
|
||||||
|
|
||||||
type Props = {
|
|
||||||
modal: { id: string, modalProps: {} },
|
|
||||||
error: { message: string },
|
|
||||||
location: { pathname: string },
|
|
||||||
hideModal: () => void,
|
|
||||||
};
|
|
||||||
|
|
||||||
function ModalRouter(props: Props) {
|
|
||||||
const { modal, error, location, hideModal } = props;
|
|
||||||
const { pathname } = location;
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
hideModal();
|
|
||||||
}, [pathname, hideModal]);
|
|
||||||
|
|
||||||
if (error) {
|
|
||||||
return <ModalError {...error} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!modal) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getModal(id) {
|
function getModal(id) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case MODALS.CONFIRM:
|
case MODALS.CONFIRM:
|
||||||
|
@ -213,6 +190,33 @@ function ModalRouter(props: Props) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
modal: { id: string, modalProps: {} },
|
||||||
|
error: { message: string },
|
||||||
|
location: { pathname: string },
|
||||||
|
hideModal: () => void,
|
||||||
|
};
|
||||||
|
|
||||||
|
function ModalRouter(props: Props) {
|
||||||
|
const { modal, error, location, hideModal } = props;
|
||||||
|
const { pathname } = location;
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
hideModal();
|
||||||
|
}, [pathname, hideModal]);
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
return (
|
||||||
|
<React.Suspense fallback={<LoadingBarOneOff />}>
|
||||||
|
<ModalError {...error} />
|
||||||
|
</React.Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!modal) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const { id, modalProps } = modal;
|
const { id, modalProps } = modal;
|
||||||
const SelectedModal = getModal(id);
|
const SelectedModal = getModal(id);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue