Skip to content
Snippets Groups Projects

fix: multifix - bug snag

Merged Adrian Orłów requested to merge bug-snag into development
21 files
+ 269
50
Compare changes
  • Side-by-side
  • Inline
Files
21
import { MOLART_ERRORS } from '@/constants/errors';
import { useAppDispatch } from '@/redux/hooks/useAppDispatch';
import { useAppSelector } from '@/redux/hooks/useAppSelector';
import { currentSelectedBioEntityIdSelector } from '@/redux/modal/modal.selector';
import { closeModal } from '@/redux/modal/modal.slice';
import { showToast } from '@/utils/showToast';
import * as MolArt from 'molart';
import * as React from 'react';
import { useEffect } from 'react';
@@ -8,12 +12,25 @@ const containerId = 'molart-container';
export const MolArtModal: React.FC = () => {
const uniprot = useAppSelector(currentSelectedBioEntityIdSelector);
const dispatch = useAppDispatch();
useEffect(() => {
const molart = new MolArt({
uniprotId: uniprot,
containerId,
});
let molart: typeof MolArt;
try {
molart = new MolArt({
uniprotId: uniprot,
containerId,
});
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
dispatch(closeModal());
showToast({
type: 'error',
message: MOLART_ERRORS.UNEXPECTED_MOLART_ERROR,
});
}
return () => {
try {
@@ -24,7 +41,7 @@ export const MolArtModal: React.FC = () => {
console.error(e);
}
};
}, [uniprot]);
}, [uniprot, dispatch]);
return (
<div className="flex h-full w-full items-center justify-center bg-white" id={containerId} />
Loading