學習Redux — 6 按下[X] 跳出confirm視窗, 詢問是否刪除

每次學習新東西都是寫Todo list實在太無趣了,這是我個人redux學習紀錄:使用react與redux開發一個留言板,並且把相關程式碼放在github上供參考

0 0yC0iqoWA2beBzrY

View

  • 這裡用到ant design 的元件 Modal.confirm

  • 寫法與js 的 confirm() 很相似

  • onOk() 裡面dispatch action: delList(id) 就完成了

    import { Modal } from 'antd';

    _onDel = (id) => {
        const confirm = Modal.confirm;
        const { delList } = this.props;
        confirm({
            title: '您是否確認要刪除留言?' ,
            onOk() {
                delList(id);
            },
            onCancel() {}
        });
    }

Originally published at github.com.




React Redux留言版相關文章:

© Justin 2022, Built with Gatsby