1

我正在为 Draft.js 使用 react-draft-wysiwyg 包装器。在页面上,我有多个 Editor 组件实例。onChange我对编辑器 UI(事件处理程序)的缓慢/滞后更新有问题。也许这是一些提示,我在控制台中收到了很多警告[Violation] 'input' handler took <N>msA

截图来自 2019-03-29 22-02-43

我的设置是:

  • 反应样板
  • 反应草稿所见即所得
  • 还原
  • 还原传奇
  • 重新选择

我正在调度操作来处理编辑器状态更改,它由 redux-saga 处理。Saga 将检查是否有新内容并更新商店。

export function* handleOnEditorStateChange({ editorState, nameSpace }) {
  const actualEditorState = yield select(selectAllEditorsContent());
  const editorIndexToUpdate = actualEditorState.findIndex(
    editors => editors.name === nameSpace,
  );
  const currentContent = actualEditorState[
    editorIndexToUpdate
  ].state.getCurrentContent();
  const newContent = editorState.getCurrentContent();

  const hasEditorNewContent = newContent !== currentContent;

  if (hasEditorNewContent) {
    const updatedEditorState = [...actualEditorState];
    updatedEditorState[editorIndexToUpdate].state = editorState;

    yield put(storeEditorStateAction(updatedEditorState));
  }
}

我的 redux 状态如下所示:

...
editors: [
    {
      name: 'editor1',
      label: 'Editor 1',
      state: {... _immutable - draftjs }
    },
    {
      name: 'editor2',
      label: 'Editor 2',
      state: {... _immutable - draftjs }
    },
]
...

减速器:

...
    case STORE_EDITOR_STATE: {
      const { content } = action;
      return state.set('editors', content);
    }
...
4

1 回答 1

0

我找到了解决我的问题的方法。至少有些人四处走动。我已经改变了我在动作观察者传奇中处理动作的方式。takaLates我没有改变效果,而是稍作throttle延迟。而且好多了。

于 2019-03-30T13:01:07.733 回答