Skip to content

Commit

Permalink
Update adding-interactivity.md
Browse files Browse the repository at this point in the history
Declare interval variable timer before use.
  • Loading branch information
2p4b authored Jan 4, 2025
1 parent 70d6cbd commit dbc31d6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/latest/getting-started/adding-interactivity.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export default function Countdown(props: { target: string }) {
// Set up an interval to update the `now` date every second with the current
// date as long as the component is mounted.
useEffect(() => {
const timer = setInterval(() => {
let timer: number = -1;
timer = setInterval(() => {
if (now.value > target) {
clearInterval(timer);
}
Expand Down

0 comments on commit dbc31d6

Please sign in to comment.