學習Redux — 6 按下[X] 跳出confirm視窗, 詢問是否刪除
March 17, 2016
每次學習新東西都是寫Todo list實在太無趣了,這是我個人redux學習紀錄:使用react與redux開發一個留言板,並且把相關程式碼放在github上供參考
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留言版相關文章:
- 學習Redux — Redux留言板實作功能介紹
- 學習Redux — 1 右上角按下[留言]的按鈕, 在modal內顯示留言的輸入框(上)
- 學習Redux — 1 右上角按下[留言]的按鈕, 在modal內顯示留言的輸入框(下)
- 學習Redux — 2 更新留言訊息
- 學習Redux — 3 按下[確認] 新增留言
- 學習Redux — 4 留言列表更新
- 學習Redux — 5 只有自己可以刪除自己的留言(自己的留言才有[x]按鈕)
- 學習Redux — 6 按下[X] 跳出confirm視窗, 詢問是否刪除
- 學習Redux — Message-board app 練習題