在redux Reducer中记录EditorState时如何使用CompositeDecorator?

时间:2018-10-30 02:18:30

标签: javascript reactjs redux draftjs

我已经构建了一个装饰器,并使用CompositeDecorator类定义了所需的装饰器行为,并且当本地状态下的editorState起作用时 但是当我将editorState升级到redux时,我不知道如何将CompositeDecorator传递给EditorState 这是editorState处于本地状态时的代码

constructor(props) {
    super(props);
    const compositeDecorator = new CompositeDecorator([
      {
        strategy: this.highlightWorngWords,
        component: HighlightedWrongWords
      }
    ]);
    this.state = {
      editorState: EditorState.createEmpty(compositeDecorator),
      subjectTitle: ""
    };

我尝试将复合Decorator放入reducer中,然后导入策略函数和decorator组件,如下所示

const  compositeDecorator = new CompositeDecorator([
  {
    strategy: highlightWorngWords,
    component: HighlightedWrongWords
  }
]);

const defaultState = {

    editorState: EditorState.createEmpty(compositeDecorator),
};

但是当我开始输入时,它在控制台中显示以下错误

  

未捕获的TypeError:无法设置未定义的属性“ props”       在组件(react.development.js:348)       在Connect(connectAdvanced.js:109)       在CompositeDraftDecorator.js:80

0 个答案:

没有答案