From ca45ba1e0d98583f7893da8b791432cc08b651e4 Mon Sep 17 00:00:00 2001 From: jiljiang Date: Fri, 2 Mar 2018 21:49:35 +0800 Subject: [PATCH] check callback before call --- src/Notification.jsx | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Notification.jsx b/src/Notification.jsx index ff483e4..7eba18d 100644 --- a/src/Notification.jsx +++ b/src/Notification.jsx @@ -102,20 +102,24 @@ Notification.newInstance = function newNotificationInstance(properties, callback return; } called = true; - callback({ - notice(noticeProps) { - notification.add(noticeProps); - }, - removeNotice(key) { - notification.remove(key); - }, - component: notification, - destroy() { - ReactDOM.unmountComponentAtNode(div); - div.parentNode.removeChild(div); - }, - }); + + if (callback) { + callback({ + notice(noticeProps) { + notification.add(noticeProps); + }, + removeNotice(key) { + notification.remove(key); + }, + component: notification, + destroy() { + ReactDOM.unmountComponentAtNode(div); + div.parentNode.removeChild(div); + }, + }); + } } + ReactDOM.render(, div); };