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
我更新了我的问题,并告诉我如何调度该操作。原来我得到了我的代码工作。我会在下面添加一个答案,但我仍在寻找更多解释。 –