Open In App

ReactJS UI Ant Design Popconfirm Component

Popconfirm is a simple and compact confirmation dialog of an action. It is basically used to ask for user confirmation.

Ant Design Library has this component pre-built, and it is very easy to integrate as well. We can use this Popconfirm component using the following process easily.



Syntax:

<Popconfirm
   title="Open Popconfirm?"
   onConfirm={confirm}
   onCancel={cancel}
   okText="Yes"
   cancelText="No"
 >
   <a href="#">Open Popconfirm</a>
 </Popconfirm>

Popconfirm Property:



Creating React Application And Installing Module:

Project Structure:

Example: Now write the following code in filename app.js.




import { Popconfirm, message } from "antd";
import "./App.css";
import "antd/dist/antd.css";
  
function App() {
  function confirm(e) {
    console.log(e);
    message.success("Click on Yes");
  }
  
  function cancel(e) {
    console.log(e);
    message.error("Click on No");
  }
  return (
    <div className="App">
      <div style={{ padding: "100px" }}>
        <h1>Demo for Popconfirm</h1>
        <Popconfirm
          title="Are you sure to delete this task?"
          onConfirm={confirm}
          onCancel={cancel}
          okText="Yes"
          cancelText="No"
        >
          <a href="#">Delete</a>
        </Popconfirm>
      </div>
    </div>
  );
}
  
export default App;

Running the application: Run the application by using the following command.

npm start

Output: Now open your browser and go to http://localhost:3000/, You will see the following output.

Reference Link: https://ant.design/components/popconfirm/


Article Tags :