Remove useless usecallback

This commit is contained in:
DefectingCat
2022-08-25 17:08:18 +08:00
parent 6a12e8508e
commit 086da74721
5 changed files with 23 additions and 27 deletions

View File

@ -1,5 +1,5 @@
import { useRouter } from 'next/router';
import { useState, useCallback, useEffect } from 'react';
import { useEffect, useState } from 'react';
/**
* Loading state when router changed.
@ -9,16 +9,12 @@ const useRouterLoading = () => {
const router = useRouter();
const [loading, setLoading] = useState(false);
const handleStart = useCallback(
(url: string) => {
url !== router.pathname ? setLoading(true) : setLoading(false);
},
[router.pathname]
);
const handleComplete = useCallback(() => {
const handleStart = (url: string) => {
url !== router.pathname ? setLoading(true) : setLoading(false);
};
const handleComplete = () => {
setLoading(false);
}, []);
};
useEffect(() => {
router.events.on('routeChangeStart', handleStart);