Skip to content

Commit

Permalink
fix ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
MayGo committed Feb 2, 2025
1 parent 7ef77c3 commit 71a464c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion client/src/components/Timeline/BarWithTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const BarWithTooltip = ({
centerTime = false,
...rest
}: PropsI) => {
const barRef = useRef();
const barRef = useRef(null);
const [hover, setHover] = useState(false);

const onMouseEnter = () => {
Expand All @@ -47,6 +47,7 @@ export const BarWithTooltip = ({

if (onClickBarItem && popoverTriggerRef) {
console.info('barRef.current', barRef.current);
// eslint-disable-next-line react-compiler/react-compiler
popoverTriggerRef.current = barRef.current;
onClickBarItem(datum);
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/eventListenerHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function App(){
}*/

// Hook
export function useEventListener(eventName, handler, element = window) {
export function useEventListener(eventName: string, handler: any, element = window) {
// Create a ref that stores handler
const savedHandler: any = useRef();
const savedHandler: any = useRef(null);

// Update ref.current value if handler changes.
// This allows our effect below to always get latest handler ...
Expand All @@ -47,7 +47,7 @@ export function useEventListener(eventName, handler, element = window) {
if (!isSupported) return;

// Create event listener that calls handler function stored in ref
const eventListener = event => savedHandler.current(event);
const eventListener = (event) => savedHandler.current(event);

// Add event listener
element.addEventListener(eventName, eventListener);
Expand Down
6 changes: 3 additions & 3 deletions client/src/hooks/intervalHook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect, useRef } from 'react';

export function useInterval(callback, delay) {
const savedCallback = useRef<any>();
export function useInterval(callback: () => void, delay: number | null): void {
const savedCallback = useRef<() => void>(() => {});

// Remember the latest callback.
useEffect(() => {
Expand All @@ -10,7 +10,7 @@ export function useInterval(callback, delay) {

// Set up the interval.
useEffect(() => {
function tick() {
function tick(): void {
savedCallback.current();
}
if (delay !== null && delay > 0) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/TimelinePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function TimelinePage() {

useInterval(() => {
bgSyncInterval();
}, [BG_SYNC_DELAY_MS]);
}, BG_SYNC_DELAY_MS);

useEffect(() => {
fetchTimerange();
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/TrayAppPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TrayAppPageTemp = () => {

useInterval(() => {
bgSyncInterval();
}, [BG_SYNC_DELAY_MS]);
}, BG_SYNC_DELAY_MS);

useEffect(() => {
fetchTimerange();
Expand Down

0 comments on commit 71a464c

Please sign in to comment.