fix(ui): safe call within useEffect teardown (#11135)
`NavProvider` useEffects teardown is trying to set `style` on an element that may not exist. The original code produces the following error:   Therefore, a condition has been added to check if `navRef.current` is truthy.
This commit is contained in:
committed by
GitHub
parent
707e85ebcf
commit
30c77d8137
@@ -96,7 +96,9 @@ export const NavProvider: React.FC<{
|
||||
// when the component unmounts, clear all body scroll locks
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
navRef.current.style.overscrollBehavior = 'auto'
|
||||
if (navRef.current) {
|
||||
navRef.current.style.overscrollBehavior = 'auto'
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user