-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Using document.querySelector to get a reference to the list container can be brittle. A more idiomatic and robust React approach is to use refs. The react-window List component provides an outerRef prop for this purpose.
You can refactor this by:
- Creating a ref for the list container:
const listContainerRef = useRef<HTMLDivElement>(null);
- Passing it to the
Listcomponent:<List // ... other props outerRef={listContainerRef} > {ViewerRow} </List>
- Using the ref in your
useEffect:const listContainer = listContainerRef.current; if (listContainer) { // ... }
This avoids querying the global document and makes the component more self-contained and predictable.
Originally posted by @gemini-code-assist[bot] in #2 (comment)
Metadata
Metadata
Assignees
Labels
No labels