Skip to content

Commit 24a26c1

Browse files
committed
🧹 remove needless imports
1 parent 556c9d1 commit 24a26c1

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

client/modules/IDE/components/Console.jsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import React, { useEffect, useRef } from 'react';
1+
import React, { useRef } from 'react';
22

33
import { bindActionCreators } from 'redux';
44

5-
import { useSelector, useDispatch, useState } from 'react-redux';
5+
import { useSelector, useDispatch } from 'react-redux';
66
import classNames from 'classnames';
77
import { Console as ConsoleFeed } from 'console-feed';
88
import {
@@ -27,18 +27,7 @@ import DownArrowIcon from '../../../images/down-arrow.svg';
2727

2828
import * as IDEActions from '../../IDE/actions/ide';
2929
import * as ConsoleActions from '../../IDE/actions/console';
30-
31-
const useDidUpdate = (callback, deps) => {
32-
const hasMount = useRef(false);
33-
34-
useEffect(() => {
35-
if (hasMount.current) {
36-
callback();
37-
} else {
38-
hasMount.current = true;
39-
}
40-
}, deps);
41-
};
30+
import { useDidUpdate } from '../../../utils/custom-hooks';
4231

4332
const getConsoleFeedStyle = (theme, times, fontSize) => {
4433
const style = {};

client/utils/custom-hooks.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React, { useEffect, useRef } from 'react';
2+
3+
export const noop = () => {};
4+
5+
export const useDidUpdate = (callback, deps) => {
6+
const hasMount = useRef(false);
7+
8+
useEffect(() => {
9+
if (hasMount.current) {
10+
callback();
11+
} else {
12+
hasMount.current = true;
13+
}
14+
}, deps);
15+
};

0 commit comments

Comments
 (0)