diff --git a/client/modules/IDE/components/Console.jsx b/client/modules/IDE/components/Console.jsx index 263ef786..cb2500c1 100644 --- a/client/modules/IDE/components/Console.jsx +++ b/client/modules/IDE/components/Console.jsx @@ -1,8 +1,8 @@ -import React, { useEffect, useRef } from 'react'; +import React, { useRef } from 'react'; import { bindActionCreators } from 'redux'; -import { useSelector, useDispatch, useState } from 'react-redux'; +import { useSelector, useDispatch } from 'react-redux'; import classNames from 'classnames'; import { Console as ConsoleFeed } from 'console-feed'; import { @@ -27,18 +27,7 @@ import DownArrowIcon from '../../../images/down-arrow.svg'; import * as IDEActions from '../../IDE/actions/ide'; import * as ConsoleActions from '../../IDE/actions/console'; - -const useDidUpdate = (callback, deps) => { - const hasMount = useRef(false); - - useEffect(() => { - if (hasMount.current) { - callback(); - } else { - hasMount.current = true; - } - }, deps); -}; +import { useDidUpdate } from '../../../utils/custom-hooks'; const getConsoleFeedStyle = (theme, times, fontSize) => { const style = {}; diff --git a/client/utils/custom-hooks.js b/client/utils/custom-hooks.js new file mode 100644 index 00000000..7e0a7b8f --- /dev/null +++ b/client/utils/custom-hooks.js @@ -0,0 +1,15 @@ +import React, { useEffect, useRef } from 'react'; + +export const noop = () => {}; + +export const useDidUpdate = (callback, deps) => { + const hasMount = useRef(false); + + useEffect(() => { + if (hasMount.current) { + callback(); + } else { + hasMount.current = true; + } + }, deps); +};