Skip to content

Commit 216f7ec

Browse files
committed
Removing unnecessary window checks
1 parent c9125a8 commit 216f7ec

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

src/utils/useFAQAccordion.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,16 @@ export const useFAQAccordion = () => {
2424
}
2525

2626
useEffect(() => {
27-
if (typeof window !== 'undefined') {
28-
const hash = window.location.hash ? window.location.hash.split("#")[1] : ""
29-
30-
if (hash && buttonCreated) {
31-
const anchor = document && document.getElementById(hash)
32-
const heading: any = anchor && anchor.parentNode
33-
34-
if (heading) {
35-
heading.parentNode.classList.toggle("open")
36-
heading.classList.toggle("open")
37-
toggleChildrenClass(heading.parentNode)
38-
}
27+
const hash = window.location.hash ? window.location.hash.split("#")[1] : ""
28+
29+
if (hash && buttonCreated) {
30+
const anchor = document && document.getElementById(hash)
31+
const heading: any = anchor && anchor.parentNode
32+
33+
if (heading) {
34+
heading.parentNode.classList.toggle("open")
35+
heading.classList.toggle("open")
36+
toggleChildrenClass(heading.parentNode)
3937
}
4038
}
4139
}, [buttonCreated])
@@ -60,14 +58,12 @@ export const useFAQAccordion = () => {
6058
e.target.localName === "button" ? e.target : e.target.parentNode
6159

6260

63-
if (typeof window !== 'undefined') {
64-
window.history.replaceState(
65-
{},
66-
"",
67-
"#" + e.target.getElementsByTagName("a")[0].id
68-
)
69-
window.history.scrollRestoration = "manual"
70-
}
61+
window.history.replaceState(
62+
{},
63+
"",
64+
"#" + e.target.getElementsByTagName("a")[0].id
65+
)
66+
window.history.scrollRestoration = "manual"
7167

7268
if (e.target.localName === "button") {
7369
e.target.classList.toggle("open")

0 commit comments

Comments
 (0)