Type error: Argument of type '() => () => string' is not assignable to parameter of type 'EffectCallback'.
useEffect(() => {
const body = document.querySelector('body') as HTMLBodyElement;
body.style.overflow = 'hidden';
return () => (body.style.overflow = 'auto');
}, []);
useEffect(() => {
body.style.overflow = 'hidden';
return () => {
body.style.overflow = 'auto';
};
}, []);
useEffect
(EffectCallback
type) should return void
or () => void | undefined
In my case, returning void ⇒ string
To fix it, add scope to the statement of the cleaning function