React-ace: 浏览器卡住,在编辑器中输入后内存不断上升

创建于 2017-07-06  ·  4评论  ·  资料来源: securingsincity/react-ace

问题

maxLines为 1 或 2,同时将onLoad设置换行模式为 true,在最后一个大括号前单击并键入 Enter 按钮使编辑器自动格式化,您会发现浏览器卡住,内存增加。

重现您的问题的示例代码

<AceEditor
      mode="json" maxLines={2} value={"{\"a\":\"b\"}"}
      onLoad={editor => editor.getSession().setUseWrapMode(true)}
/>

或访问简单的项目react-ace-editor-issuse

参考

初始内存和 CPU
tim 20170706095723
输入 Enter 按钮后 10 秒
tim 20170706095813

进展:#
Win 10 / Chrome 58&IE 11/ React 15.6.1

bug unable to reproduce

最有用的评论

我正在使用 React v16.4,react-ace v6.1.2

  1. 使用create-react-app
  2. 并使用下面的代码进行测试,使用maxLineswrapEnabled设置 AceEditor
class App extends React.Component {
  render() {

    const props = {
      mode: 'javascript',
      theme: 'monokai',
      value: 'const test = \'hello loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text\'',
      maxLines: 1,
      wrapEnabled: true,
    };

    return (
      <div>
        <AceEditor {...props} />
      </div>
    );
  }
}

它会导致cpu和内存升高
image

所有4条评论

我们考虑远离https://github.com/JedWatson/react-codemirror,因为至少目前它维护得不好(也就是维护者不合并或对 PR 做出反应),但这里有一个阻止程序.

@SecMao我无法在我的 Mac 上重现。 我需要找一台 Windows 笔记本电脑来重现。

@inoas你能重现这个问题吗? 我看到一些评论提到您希望从 codemirror 切换,但不清楚您是否在本地看到这些问题。

我们还没有采取行动,如果我们这样做并在任何一种情况下都报告(没有泄漏或“看起来像”泄漏),我们将尝试重现这一点

我正在使用 React v16.4,react-ace v6.1.2

  1. 使用create-react-app
  2. 并使用下面的代码进行测试,使用maxLineswrapEnabled设置 AceEditor
class App extends React.Component {
  render() {

    const props = {
      mode: 'javascript',
      theme: 'monokai',
      value: 'const test = \'hello loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text\'',
      maxLines: 1,
      wrapEnabled: true,
    };

    return (
      <div>
        <AceEditor {...props} />
      </div>
    );
  }
}

它会导致cpu和内存升高
image

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

danush picture danush  ·  7评论

huangjiatian picture huangjiatian  ·  7评论

levi0913 picture levi0913  ·  7评论

viridia picture viridia  ·  4评论

venil7 picture venil7  ·  3评论