1
當前正在執行響應通知,但遇到一個錯誤,表示Cannot read property 'preventDefault' of undefined
,我認爲這意味着傳入_addNotification的事件未定義。無法找到響應通知
_handleSuccess: function(data, status, jqXHR) {
this._addNotification()
this.setState({
errors: {},
loading: false
});
},
_notificationSystem: null,
_addNotification: function(event) {
event.preventDefault()
this._notificationSystem.addNotification({
message: 'Notification message',
level: 'success',
position: 'bc'
});
},
_componentDidMount: function() {
this._notificationSystem = this.refs.notificationSystem;
},
_getNotificationSystemInstance: function() {
return this
},
謝謝!這確實解決了這個問題,但是它提出了'Can not read property'addNotification'null'的後續問題,這意味着它不會向null _notificationSystem添加通知。但是,這似乎與文檔[此處](https://github.com/igorprado/react-notification-system#creating-a-notification)相反。不知道這是否也是一個快速修復或值得自己的問題。 –