import { Button, message, Popconfirm, Switch } from 'antd'; import React, { useState } from 'react'; const App: React.FC = () => { const [open, setOpen] = useState(false); const [condition, setCondition] = useState(true); const changeCondition = (checked: boolean) => { setCondition(checked); }; const confirm = () => { setOpen(false); message.success('Next step.'); }; const cancel = () => { setOpen(false); message.error('Click on cancel.'); }; const handleOpenChange = (newOpen: boolean) => { if (!newOpen) { setOpen(newOpen); return; } // Determining condition before show the popconfirm. console.log(condition); if (condition) { confirm(); // next step } else { setOpen(newOpen); } }; return (


Whether directly execute:
); }; export default App;