Skip to content

Commit 5561f28

Browse files
authored
minor: change incorrect createRef to useRef (#2455)
change incorrect createRef to useRef, fix dep array in useSteppedScroll
1 parent 5640bf9 commit 5561f28

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

app/ui/lib/ActionMenu.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import * as Dialog from '@radix-ui/react-dialog'
99
import cn from 'classnames'
1010
import { matchSorter } from 'match-sorter'
11-
import React, { useState } from 'react'
11+
import { useRef, useState } from 'react'
1212

1313
import { Close12Icon } from '@oxide/design-system/icons/react'
1414

@@ -70,9 +70,9 @@ export function ActionMenu(props: ActionMenuProps) {
7070
const [selectedIdx, setSelectedIdx] = useState(0)
7171
const selectedItem = itemsInOrder[selectedIdx] as QuickActionItem | undefined
7272

73-
const divRef = React.createRef<HTMLDivElement>()
74-
const ulRef = React.createRef<HTMLUListElement>()
75-
const inputRef = React.createRef<HTMLInputElement>()
73+
const divRef = useRef<HTMLDivElement>(null)
74+
const ulRef = useRef<HTMLUListElement>(null)
75+
const inputRef = useRef<HTMLInputElement>(null)
7676

7777
useSteppedScroll(divRef, ulRef, selectedIdx, LIST_HEIGHT)
7878

app/ui/lib/use-stepped-scroll.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ export function useSteppedScroll(
6767
outer.scrollTo({ top: itemBottomScrollTo - outerContainerHeight + 2 })
6868
}
6969
}
70-
// don't depend on the refs because they get nuked on every render
71-
// eslint-disable-next-line react-hooks/exhaustive-deps
72-
}, [outerContainerHeight, selectedIdx, itemSelector])
70+
}, [
71+
outerContainerRef,
72+
innerContainerRef,
73+
outerContainerHeight,
74+
selectedIdx,
75+
itemSelector,
76+
])
7377
}

0 commit comments

Comments
 (0)