Skip to content

Commit

Permalink
tsc error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doggan committed Sep 7, 2023
1 parent 943a219 commit f35ed4d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 41 deletions.
4 changes: 3 additions & 1 deletion packages/desktop-client/src/components/AnimatedRefresh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default function AnimatedRefresh({
}: AnimatedRefreshProps) {
return (
<View
style={{ animation: animating ? `${spin} 1s infinite linear` : null }}
style={{
animation: animating ? `${spin} 1s infinite linear` : undefined,
}}
>
<Refresh width={14} height={14} style={iconStyle} />
</View>
Expand Down
24 changes: 1 addition & 23 deletions packages/desktop-client/src/components/sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,17 @@ import React, {
useEffect,
useRef,
useLayoutEffect,
useMemo,
useState,
useContext,
type RefCallback,
type MutableRefObject,
type Context,
type Ref,
} from 'react';
import { useDrag, useDrop } from 'react-dnd';

import { useMergedRefs } from '../hooks/useMergedRefs';
import { theme } from '../style';

import View from './common/View';

function useMergedRefs<T>(
ref1: RefCallback<T> | MutableRefObject<T>,
ref2: RefCallback<T> | MutableRefObject<T>,
): Ref<T> {
return useMemo(() => {
function ref(value) {
[ref1, ref2].forEach(ref => {
if (typeof ref === 'function') {
ref(value);
} else if (ref != null) {
ref.current = value;
}
});
}

return ref;
}, [ref1, ref2]);
}

type DragState = {
state: 'start-preview' | 'start' | 'end';
type?: string;
Expand Down
17 changes: 0 additions & 17 deletions packages/desktop-client/src/hooks/useMergedRefs.js

This file was deleted.

25 changes: 25 additions & 0 deletions packages/desktop-client/src/hooks/useMergedRefs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import {
type MutableRefObject,
type Ref,
type RefCallback,
useMemo,
} from 'react';

export function useMergedRefs<T>(
ref1: RefCallback<T> | MutableRefObject<T>,
ref2: RefCallback<T> | MutableRefObject<T>,
): Ref<T> {
return useMemo(() => {
function ref(value: T) {
[ref1, ref2].forEach(ref => {
if (typeof ref === 'function') {
ref(value);
} else if (ref != null) {
ref.current = value;
}
});
}

return ref;
}, [ref1, ref2]);
}

0 comments on commit f35ed4d

Please sign in to comment.