Fix updateHash function throwing errors when there are no headings visible at the screen (#125)

This commit is contained in:
Szymon Kin 2022-12-08 15:27:06 +01:00 committed by GitHub
parent a2f056f536
commit ec12e57ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -18,6 +18,8 @@ const updateHash = (data: Data) => {
})
.filter((section) => section.bottom > 0);
if (distancesToHeadingBottom.length === 0) return;
const currentSection = distancesToHeadingBottom.reduce((previous, current) =>
previous.bottom < current.bottom ? previous : current
);