Optimize util structure
This commit is contained in:
16
src/util/hooks.tsx
Normal file
16
src/util/hooks.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React from 'react'
|
||||
|
||||
export const useUpdatedEffect = (
|
||||
effect: React.EffectCallback,
|
||||
dependencies: React.DependencyList
|
||||
) => {
|
||||
const isFirstRender = useRef(true)
|
||||
|
||||
useEffect(() => {
|
||||
if (isFirstRender.current) {
|
||||
isFirstRender.current = false
|
||||
} else {
|
||||
effect()
|
||||
}
|
||||
}, dependencies)
|
||||
}
|
||||
Reference in New Issue
Block a user