2
我試圖在減速器中做到這一點;爲什麼我在React Redux Reducer中收到有關合成事件的警告?
case actions.DATA_RETURNED:
newState = Object.assign({}, state);
newState.status = 'complete';
if (resp) {
var newItems = newState.items.map(item => {
var newItem = Object.assign({}, item);
var match = _.find(resp, { id: item._id });
newItem._rev = match.rev;
return newItem;
});
}
break;
我試過幾種變化,他們都失敗了;
warning.js:36 Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property cancelable on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist(). See https://facebook.github.io/react/docs/events.html#event-pooling for more information.
除非我除去newItem._rev = match.rev
或設置match
是一個硬編碼的字符串。所以看起來問題在於試圖在Array.map
裏使用lodash的find
,但我不明白爲什麼這是一個問題。我並沒有自覺地對事件做任何事情,所以我很難找到解決方案。
編輯:如果它是相關的,這裏是我如何派遣的行動;
return syncChangedItemsToDB(itemsChanged).then((resp) => {
dispatch({type: actions.DATA_RETURNED, resp});
});
有沒有人知道是什麼原因導致了這個警告,我該如何解決它?
這是關於反應事件,您的代碼中沒有可見的事件。你可以在哪裏發佈你的動作? – Maxx
我更新了我的問題,並告訴我如何調度該操作。原來我得到了我的代碼工作。我會在下面添加一個答案,但我仍在尋找更多解釋。 –