mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-27 18:56:58 +00:00
✨(frontend) introduce usePrevious utility hook
Add new usePrevious utility hook to track previous values in functional components. Enables comparing current and previous prop/state values across renders for improved state management.
This commit is contained in:
committed by
aleb_the_flash
parent
3eef4765df
commit
b248395cd6
@@ -0,0 +1,9 @@
|
|||||||
|
import { useEffect, useRef } from 'react'
|
||||||
|
|
||||||
|
export const usePrevious = <T>(value: T): T | undefined => {
|
||||||
|
const ref = useRef<T>()
|
||||||
|
useEffect(() => {
|
||||||
|
ref.current = value
|
||||||
|
}, [value])
|
||||||
|
return ref.current
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user