Skip to content

Commit

Permalink
Rewrite debounce using lodash's
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyoho committed Nov 23, 2024
1 parent b42c103 commit 1bc72c7
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import PropTypes from 'prop-types';
import React from 'react';

import { debounce } from 'lodash';

import emojify from '../../emoji/emoji';
import { debounce } from 'react-decoration';


/* global MathJax */
// const loadScriptOnce = require('load-script-once');
Expand All @@ -16,9 +19,7 @@ class LivePreview extends React.PureComponent {
};
}

// @debounce(375)
// TODO: Fix it not to use decoration
changeTextToRender() {
changeTextToRender = debounce(() => {
const text = this.props.text.replace(/\n/g, '<br>');

this.setState({ textToRender: text });
Expand All @@ -27,7 +28,9 @@ class LivePreview extends React.PureComponent {
if (MathJax !== undefined) {
MathJax.Hub.Queue(['Typeset', MathJax.Hub, node]);
}
}
}, 375, {
trailing: true,
})

componentWillUpdate() {
}
Expand Down

0 comments on commit 1bc72c7

Please sign in to comment.