Skip to content

Commit

Permalink
fix: fixed runtime error that occurs because, classList reading prope…
Browse files Browse the repository at this point in the history
…rties of null (#218)

* Fixed runtime error that occurs because, classList reading properties of NULL

* Fixed runtime error bug.

* added optional chain expression
  • Loading branch information
Vibgitcode27 authored Oct 13, 2023
1 parent 096bcf3 commit dbe5b3f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/Countdown/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ function Countdowns() {
dateRef.current.classList.add('home-title');
setSelectedIndex((prevIndex) => (prevIndex + 1) % dates.length);
setTimeout(() => {
locationRef.current.classList.remove('home-title');
locationRef.current.classList.add('hidden');
dateRef.current.classList.remove('home-title');
dateRef.current.classList.add('hidden');
if(locationRef?.current) {
locationRef.current.classList.remove('home-title');
locationRef.current.classList.add('hidden');
}
if(dateRef?.current) {
dateRef.current.classList.remove('home-title');
dateRef.current.classList.add('hidden');
}
}, 9900); // Element stays visible for 800 milliseconds
}, 10000); // Toggle visibility every 1500 milliseconds

Expand Down

0 comments on commit dbe5b3f

Please sign in to comment.