Closed joshuabaker closed 1 year ago
If the element ($anchor) is not present the subsequent call to getBoundingClientRect() will throw an exception.
$anchor
getBoundingClientRect()
What’s your thoughts on wrapping this with a try...catch?
try...catch
TypeError: Cannot read property 'getBoundingClientRect' of null
https://github.com/mauricevancooten/react-anchor-link-smooth-scroll/blob/1f86d5e868e0b4efeb97a750b836561de3813226/src/anchor-link.js#L22-L23
If the element (
$anchor
) is not present the subsequent call togetBoundingClientRect()
will throw an exception.What’s your thoughts on wrapping this with a
try...catch
?Exception
Source
https://github.com/mauricevancooten/react-anchor-link-smooth-scroll/blob/1f86d5e868e0b4efeb97a750b836561de3813226/src/anchor-link.js#L22-L23