From 24a26c16c2d399696db293b0d14cebe3cbccdc2b Mon Sep 17 00:00:00 2001 From: ghalestrilo Date: Mon, 20 Jul 2020 19:08:03 -0300 Subject: [PATCH] :broom: remove needless imports --- client/modules/IDE/components/Console.jsx | 17 +++-------------- client/utils/custom-hooks.js | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) create mode 100644 client/utils/custom-hooks.js 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); +};