How to add popconfirm in antd design to file delete action


jasper

I am using the Antd Design library in my React app. I have a form with file upload

I want to show PopConfirm every time the user tries to delete the uploaded file . But here's the problem: PopConfirm requires React Element as a child, and antd uploader doesn't seem to provide access to it.

But maybe there are other solutions?

I've seen this question: How to add PopConfirm for removeFile an image file in ant-d upload

But solved the problem by showing the modal. This is not what I want. PopConfirm is always used elsewhere in the app, and where will the modal be used for some reason. I really hope there is a solution.

Dennis Wash

There is no built-in way to do this.

The cleanest way is to use Modal:

function App() {
  const [visible, setVisible] = useState(false);
  const toggle = () => setVisible(prev => !prev);
  return (
    <div>
      <Modal okText="Yes" cancelText="No" visible={visible} onCancel={toggle}>
        Are you sure delete this task?
      </Modal>
      <Upload {...props} onRemove={toggle}>
        <Button>
          <Icon type="upload" /> Click to Upload
        </Button>
      </Upload>
    </div>
  );
}

The only solution is to implement your own Uploadcomponent antdand use Popconfirmon the component that uploads the file .

Related


How to add popconfirm in antd design to file delete action

jasper I am using the Antd Design library in my React app. I have a form with file upload I want to show PopConfirm every time the user tries to delete the uploaded file . But here's the problem: PopConfirm requires React Element as a child, and antd uploader

How to add custom image/icon in ANTD design menu?

Johnny Shruder Using this example : https://ant.design/components/layout/#components-layout-demo-side How to add custom image or icon instead of default icon. I tried: <Menu.Item to="/" key="2"> <img className="ant-menu-item" src={require('image.png')} />

How to add custom image/icon in ANTD design menu?

Johnny Shruder Using this example : https://ant.design/components/layout/#components-layout-demo-side How to add custom image or icon instead of default icon. I tried: <Menu.Item to="/" key="2"> <img className="ant-menu-item" src={require('image.png')} />

How to add custom image/icon in ANTD design menu?

Johnny Shruder Using this example : https://ant.design/components/layout/#components-layout-demo-side How to add custom image or icon instead of default icon. I tried: <Menu.Item to="/" key="2"> <img className="ant-menu-item" src={require('image.png')} />

How to add a material design library switch in the action bar

Abhilash anand How to insert com.gc.materialdesign.views.Switchin Actionbaruse MenuInflater? Below is the code to inflate the android default switch. this is mineonCreateOptionsMenu @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater

How to add a material design library switch in the action bar

Abhilash anand How to insert com.gc.materialdesign.views.Switchin Actionbaruse MenuInflater? Below is the code to inflate the android default switch. this is mineonCreateOptionsMenu @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater

How to add a material design library switch in the action bar

Abhilash anand How to insert com.gc.materialdesign.views.Switchin Actionbaruse MenuInflater? Below is the code to inflate the android default switch. this is mineonCreateOptionsMenu @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

How to add antd pagination component?

Will Black I want to add Antd Pagination ( documents ) to an item in the "ArticlesList" component, but don't know yet - I should pass the Pagination component to onChange = {????}Tried to produce different variants, but it doesn't work. Any help or suggestion

Ant Design Popconfirm - Change preselect button to "Cancel"

Michael Zech Popconfirm-modal in Ant Design has a preselected Confirm ("Yes"-) button when the modal window is open. The source code of the modal: import { Popconfirm, message } from 'antd'; function confirm(e) { console.log(e); message.success('Click on

Ant Design Popconfirm - Change preselect button to "Cancel"

Michael Zech Popconfirm-modal in Ant Design has a preselected Confirm ("Yes"-) button when the modal window is open. The source code of the modal: import { Popconfirm, message } from 'antd'; function confirm(e) { console.log(e); message.success('Click on

Ant Design Popconfirm - Change preselect button to "Cancel"

Michael Zech Popconfirm-modal in Ant Design has a preselected Confirm ("Yes"-) button when the modal window is open. The source code of the modal: import { Popconfirm, message } from 'antd'; function confirm(e) { console.log(e); message.success('Click on

Ant Design Popconfirm - Change preselect button to "Cancel"

Michael Zech Popconfirm-modal in Ant Design has a preselected Confirm ("Yes"-) button when the modal window is open. The source code of the modal: import { Popconfirm, message } from 'antd'; function confirm(e) { console.log(e); message.success('Click on

How to add delete action to each row with value id

joepa37 So I'm having trouble adding an action to each row to delete the selected row that takes the ID from the "Value" column, since the "Delete" column has - in all cells. I have ButtonRenderer and ButtonEditor to add button to JTable ButtonRenderer import

How to add delete action to each row with value id

joepa37 So I'm having trouble adding an action to each row to delete the selected row that takes the ID from the "Value" column, since the "Delete" column has - in all cells. I have ButtonRenderer and ButtonEditor to add button to JTable ButtonRenderer import

How do you tell git that delete and add are really an action?

Daniel Kaplan Most of the time, git can figure out when I moved a file, but sometimes it can't. Is there a way to tell git, "Trust me, this is a move?" A key component of this is that I'm using a tool to rename files. Must revert renaming and try again as git

How to add/delete lines in a text file?

the_no_1 I'm not sure how to give the user the option to add/remove names from the existing text file. The current code works fine and can read the names from the text file. Can someone help me with this? import java.io.File; import java.util.Scanner; public

How to add/delete lines in a text file?

the_no_1 I'm not sure how to give the user the option to add/remove names from the existing text file. The current code works fine and can read the names from the text file. Can someone help me with this? import java.io.File; import java.util.Scanner; public

How to delete an associated action?

username Learn iOS development and follow tutorials on Apple's website. After connecting the button to the view controller code (via ctl-drag), I decided to rename the action. Instead of refactoring, I removed the code section and reconnected (via ctl-drag). N

How to delete an associated action?

username Learn iOS development and follow tutorials on Apple's website. After connecting the button to the view controller code (via ctl-drag), I decided to rename the action. Instead of refactoring, I removed the code section and reconnected (via ctl-drag). N

How to delete an associated action?

username Learn iOS development and follow tutorials on Apple's website. After connecting the button to the view controller code (via ctl-drag), I decided to rename the action. Instead of refactoring, I removed the code section and reconnected (via ctl-drag). N