Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

✨(frontend) introduce usePrevious utility hook

lebaudantoineb248395cd68d
diff --git a/src/frontend/src/hooks/usePrevious.ts b/src/frontend/src/hooks/usePrevious.ts
new file mode 100644
index 00000000..ff79f7e9
--- /dev/null
+++ b/src/frontend/src/hooks/usePrevious.ts
@@ -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
+}