Skip to content

Commit

Permalink
CM-1160: Change the default value of alert state (#1150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayumi-oxd authored Jan 4, 2024
1 parent 8574406 commit 473de22
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/gatsby/src/components/emergencyAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,7 @@ const EmergencyAlert = () => {
)
characterCount = descriptionCount + linkTextCount
}
const [show, setShow] = useState(() => {
if (typeof window !== "undefined" && window.sessionStorage) {
const storedAlertValue = sessionStorage.getItem("alert")
return storedAlertValue !== "false"
}
return true
})
const [show, setShow] = useState(false)

const handleClick = () => {
setShow(false)
Expand All @@ -52,13 +46,12 @@ const EmergencyAlert = () => {
}
}

// prevent the alert flash for the first mount
useEffect(() => {
if (typeof window !== "undefined" && window.sessionStorage) {
const storedAlertValue = sessionStorage.getItem("alert")
if (storedAlertValue !== null) {
setShow(storedAlertValue !== "false")
}
setShow(storedAlertValue !== "false")
} else {
setShow(true)
}
}, [])

Expand Down

0 comments on commit 473de22

Please sign in to comment.