Skip to content

Conversation

@e-yushkiavichus
Copy link

@gravity-ui
Copy link
Contributor

gravity-ui bot commented Dec 2, 2025

Preview is ready.

@gravity-ui
Copy link
Contributor

gravity-ui bot commented Dec 2, 2025

🎭 Component Tests Report is ready.

ref={
this.state.columnHeaderRefs[
index
] as React.Ref<HTMLTableCellElement>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to cast type here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

columnHeaderRefs is typed as React.RefObject<HTMLTableCellElement | null>[] (to align with React 19, where RefObject<T> no longer allows null in current without explicit typing). When accessing this.state.columnHeaderRefs[index], we get RefObject<HTMLTableCellElement | null>, while the ref prop on <th> expects Ref<HTMLTableCellElement> (which is RefCallback<T> | RefObject<T> | null).

TypeScript treats RefObject<HTMLTableCellElement | null> as structurally incompatible with RefObject<HTMLTableCellElement> (even though they're functionally equivalent at runtime, since both have current: HTMLTableCellElement | null). The assertion bridges this structural type mismatch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants