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