Refactor(TS): Rename some file from *.tsx to *.ts

This commit is contained in:
2024-05-06 15:25:08 +08:00
parent ef653c20f8
commit 5e6c8f214c
8 changed files with 2 additions and 2 deletions

21
src/util/hooks.ts Normal file
View File

@@ -0,0 +1,21 @@
import { DependencyList, EffectCallback } from 'react'
export const useUpdatedEffect = (effect: EffectCallback, dependencies: DependencyList) => {
const isFirstRender = useRef(true)
useEffect(() => {
if (isFirstRender.current) {
isFirstRender.current = false
} else {
return effect()
}
}, dependencies)
}
export const usePrevious = <T,>(value: T): T | undefined => {
const ref = useRef<T>()
useEffect(() => {
ref.current = value
})
return ref.current
}