only update snippet when component is mounted (#191)

* only update snippet when component is mounted

fixing: #190

* removed debug console.log
This commit is contained in:
Erik Jan de Wit 2020-10-29 18:02:06 +01:00 committed by GitHub
parent b618ab245e
commit 52afed2b64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import {
AlertVariant,
Form,
FormGroup,
ModalVariant,
Select,
SelectOption,
SelectVariant,
@ -66,13 +67,19 @@ export const DownloadDialog = ({
const [openType, setOpenType] = useState(false);
useEffect(() => {
let isMounted = true;
(async () => {
const response = await httpClient.doGet<string>(
`/admin/realms/${realm}/clients/${id}/installation/providers/${selected}`
);
setSnippet(await response.text());
if (isMounted) {
setSnippet(await response.text());
}
})();
}, [selected, snippet]);
return () => {
isMounted = false;
};
}, [selected]);
return (
<ConfirmDialogModal
titleKey={t("clients:downloadAdaptorTitle")}
@ -86,6 +93,7 @@ export const DownloadDialog = ({
}}
open={open}
toggleDialog={toggleDialog}
variant={ModalVariant.medium}
>
<Form>
<Stack hasGutter>