My project involves creating cards (like flashcards) that involve React Ace to write or edit code.
(我的项目涉及创建涉及React Ace的卡(如抽认卡)来编写或编辑代码。)
A user's home page can have more than one flashcard. (用户的主页可以具有多个抽认卡。)
(For working project check here - https://visit-sparkle.apricity.co.in . There is a "demo" section for those who prefer TL;DR) ((有关工作项目的信息,请在此处-https://visit-sparkle.apricity.co.in 。对于喜欢TL; DR的人员,有一个“演示”部分))
Now, while these cards load alright, there is a major performance implication which I believe is due to non-passive event handling by React-ace which is resulting in a blocking piece of code that slows down my page's rendering very very badly.
(现在,尽管这些卡可以正常加载,但我认为这是一个主要的性能暗示,这是由于React-ace的非被动事件处理所致,这导致了一段代码阻塞,这非常严重地减慢了我页面的呈现速度。)
Performance cost due to this:
(由于此而导致的性能成本:)
Code to reproduce:
(复制代码:)
<AceEditor
mode="python"
theme="dracula"
name={`CodeEditor-1`}
onChange={this.handleCodeChanges}
fontSize={14}
showPrintMargin={true}
showGutter={true}
highlightActiveLine={true}
value={this.props.code}
readOnly={!this.props.editState}
height='150px'
width='100%'
editorProps={{ $blockScrolling: false}} //I've tried this but does not seem to help
/>
Google is suggesting to enforce an object with {passive: true} to radically improve performance.
(Google建议使用{passive:true}强制执行一个对象,以从根本上提高性能。)
How can we enable this with React-Ace? (我们如何使用React-Ace启用它?)
Their documentation does not seem to help. (他们的文档似乎没有帮助。)
Appreciate all help.
(感谢所有帮助。)
Thanks (谢谢)
ask by Pruthvi Kumar translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…