mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-23 14:23:21 +00:00
Compare commits
3 Commits
92487d2f52
...
memoizeBre
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0fd3448826 | ||
|
|
3bd73417e6 | ||
|
|
72b69ebb6a |
@@ -1,7 +1,7 @@
|
|||||||
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
/*eslint max-lines: ["warn", {"max": 300, "skipBlankLines": true, "skipComments": true}]*/
|
||||||
require('./brewRenderer.less');
|
require('./brewRenderer.less');
|
||||||
const React = require('react');
|
const React = require('react');
|
||||||
const { useState, useRef, useCallback } = React;
|
const { useState, useRef, useCallback, memo } = React;
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
|
const MarkdownLegacy = require('naturalcrit/markdownLegacy.js');
|
||||||
@@ -47,7 +47,7 @@ const BrewPage = (props)=>{
|
|||||||
const renderedPages = [];
|
const renderedPages = [];
|
||||||
let rawPages = [];
|
let rawPages = [];
|
||||||
|
|
||||||
const BrewRenderer = (props)=>{
|
const BrewRenderer = memo((props)=>{
|
||||||
props = {
|
props = {
|
||||||
text : '',
|
text : '',
|
||||||
style : '',
|
style : '',
|
||||||
@@ -224,6 +224,19 @@ const BrewRenderer = (props)=>{
|
|||||||
</Frame>
|
</Frame>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
}, arePropsEqual);
|
||||||
|
|
||||||
|
//Only re-render brewRenderer if arePropsEqual == true
|
||||||
|
function arePropsEqual(oldProps, newProps) {
|
||||||
|
return (
|
||||||
|
oldProps?.text?.length === newProps?.text?.length &&
|
||||||
|
oldProps?.style?.length === newProps?.style?.length &&
|
||||||
|
oldProps?.renderer === newProps?.renderer &&
|
||||||
|
oldProps?.theme === newProps?.theme &&
|
||||||
|
oldProps?.errors === newProps?.errors &&
|
||||||
|
oldProps?.themeBundle === newProps?.themeBundle &&
|
||||||
|
oldProps?.lang === newProps?.lang
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = BrewRenderer;
|
module.exports = BrewRenderer;
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ const Editor = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
sourceJump : function(targetPage=this.props.currentBrewRendererPageNum, smooth=true){
|
sourceJump : function(targetPage=this.props.currentBrewRendererPageNum, smooth=true){
|
||||||
if(!this.isText || isJumping)
|
if(!this.isText() || isJumping)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const textSplit = this.props.renderer == 'V3' ? /^\\page$/gm : /\\page/;
|
const textSplit = this.props.renderer == 'V3' ? /^\\page$/gm : /\\page/;
|
||||||
|
|||||||
Reference in New Issue
Block a user