🐛(fix) fix body scroll when a modal is opened

It was possible to scroll the body when a modal is opened, it was
cutting the visibility of the modal, and was simply weird.

Fixes #263
This commit is contained in:
Nathan Vasse
2024-02-19 15:26:08 +01:00
committed by NathanVss
parent e9956829d1
commit 7f12f4d9b0
5 changed files with 254 additions and 1 deletions

View File

@@ -0,0 +1,19 @@
import { useEffect, useRef } from "react";
/**
* Hook which stores the previous value of a component prop or state.
* https://usehooks.com/usePrevious/
*
* @param value
*/
const usePrevious = <T>(value: T): T => {
const previous = useRef<T>(value);
useEffect(() => {
previous.current = value;
}, [value]);
return previous.current;
};
export default usePrevious;