Specifically use window.setTimeout to not confuse types with Nodes global.setTimeout

This commit is contained in:
Marcus Eide
2020-05-19 14:14:30 +02:00
parent 0b884d64f6
commit 7edefcf36d
+3 -3
View File
@@ -74,7 +74,7 @@ export const Sidebar: FC<Props> = ({
}) => {
const classes = useStyles();
const [state, setState] = useState(State.Closed);
const hoverTimerRef = useRef<NodeJS.Timer>();
const hoverTimerRef = useRef<number>();
const handleOpen = () => {
if (hoverTimerRef.current) {
@@ -82,7 +82,7 @@ export const Sidebar: FC<Props> = ({
hoverTimerRef.current = undefined;
}
if (state !== State.Open) {
hoverTimerRef.current = setTimeout(() => {
hoverTimerRef.current = window.setTimeout(() => {
hoverTimerRef.current = undefined;
setState(State.Open);
}, openDelayMs);
@@ -99,7 +99,7 @@ export const Sidebar: FC<Props> = ({
if (state === State.Peek) {
setState(State.Closed);
} else if (state === State.Open) {
hoverTimerRef.current = setTimeout(() => {
hoverTimerRef.current = window.setTimeout(() => {
hoverTimerRef.current = undefined;
setState(State.Closed);
}, closeDelayMs);