useDisclosure instead of useState.

This commit is contained in:
mickr777 2023-07-13 18:08:30 +10:00 committed by GitHub
parent d1ac50b061
commit 91c4e4c9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { useState } from 'react';
import { useDisclosure } from '@chakra-ui/react';
import {
AlertDialog,
AlertDialogBody,
@ -22,10 +22,10 @@ import IAIIconButton from 'common/components/IAIIconButton';
const ClearNodesButton = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch();
const [isDialogOpen, setIsDialogOpen] = useState(false);
const { isOpen, onOpen, onClose } = useDisclosure();
const handleClearNodes = () => {
setIsDialogOpen(true);
onOpen();
};
const handleConfirmClear = () => {
@ -40,11 +40,11 @@ const ClearNodesButton = () => {
)
);
setIsDialogOpen(false);
onClose();
};
const handleCancelClear = () => {
setIsDialogOpen(false);
onClose();
};
return (
@ -56,12 +56,7 @@ const ClearNodesButton = () => {
onClick={handleClearNodes}
/>
<AlertDialog
isOpen={isDialogOpen}
leastDestructiveRef={undefined}
onClose={handleCancelClear}
isCentered
>
<AlertDialog isOpen={isOpen} onClose={handleCancelClear} isCentered>
<AlertDialogOverlay />
<AlertDialogContent>