Skip to content

Commit

Permalink
fix: timeout handle overload building
Browse files Browse the repository at this point in the history
  • Loading branch information
VodBox committed Jan 12, 2024
1 parent 61520d9 commit e201a32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/channels/minesweeper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ export function Minesweeper(props: ChannelProps) {
const [gridState, dispatch] = useReducer(gridReducer, cloneDeep(stateReplicant.value!));

const [face, setFace] = useState<FaceType>('smile');
const faceChangeTimeout = useRef<NodeJS.Timeout>();
const faceChangeTimeout = useRef<ReturnType<typeof setTimeout>>();

function changeFace(face: FaceType) {
clearTimeout(faceChangeTimeout.current);
clearTimeout(faceChangeTimeout.current!);
setFace(face);
faceChangeTimeout.current = setTimeout(() => setFace('smile'), 2_500);
}
Expand All @@ -179,7 +179,7 @@ export function Minesweeper(props: ChannelProps) {
}
}, [gridState.nonMines]);

const flagTimeoutRef = useRef<NodeJS.Timeout>();
const flagTimeoutRef = useRef<ReturnType<typeof setTimeout>>();
useEffect(() => {
function flagTiles(timeoutMS: number) {
// Add a question mark every 5-10 seconds
Expand All @@ -193,7 +193,7 @@ export function Minesweeper(props: ChannelProps) {
flagTiles(5_000);

return () => {
clearTimeout(flagTimeoutRef.current);
clearTimeout(flagTimeoutRef.current!);
};
}, []);

Expand Down

0 comments on commit e201a32

Please sign in to comment.