diff --git a/package.json b/package.json index 622f630..e71fcd7 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "redux-devtools": "^3.0.0" }, "dependencies": { + "lodash.debounce": "^4.0.4", "react-json-tree": "^0.6.5", "react-pure-render": "^1.0.2", "redux-devtools-themes": "^1.0.0" diff --git a/src/LogMonitor.js b/src/LogMonitor.js index 8700961..0049315 100644 --- a/src/LogMonitor.js +++ b/src/LogMonitor.js @@ -6,6 +6,7 @@ import { ActionCreators } from 'redux-devtools'; import { updateScrollTop } from './actions'; import reducer from './reducers'; import LogMonitorEntryList from './LogMonitorEntryList'; +import debounce from 'lodash.debounce'; const { reset, rollback, commit, sweep, toggleAction } = ActionCreators; @@ -39,14 +40,6 @@ const styles = { } }; -const debounced = (func, wait) => { - let timeout; - return () => { - clearTimeout(timeout); - timeout = setTimeout(func, wait); - }; -}; - export default class LogMonitor extends Component { static update = reducer; @@ -80,7 +73,7 @@ export default class LogMonitor extends Component { shouldComponentUpdate = shouldPureComponentUpdate; - updateScrollTop = debounced(() => { + updateScrollTop = debounce(() => { const node = this.refs.container; this.props.dispatch(updateScrollTop(node ? node.scrollTop : 0)); }, 500);