-
Notifications
You must be signed in to change notification settings - Fork 155
feat: polish types to be compatible with React 18.3 #4735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
LLM Analysis of PR ChangesSummaryThis PR updates the React and React DOM dependencies to be compatible with React 18.3, loosening the version constraints. It also fixes type issues by casting refs to Key Points to Review
Style & Consistency
|
3b98f1e
to
b21d412
Compare
Deploying orbit with
|
Latest commit: |
9699cd9
|
Status: | ✅ Deploy successful! |
Preview URL: | https://fa9d3b10.orbit.pages.dev |
Branch Preview URL: | https://sarka-react-upgrade-fix.orbit.pages.dev |
Size Change: +34 B (+0.01%) Total Size: 464 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
The incorrect return type React.RefObject<T>
that doesn't account for null values could lead to runtime errors if not handled properly. Suppressing type errors with // @ts-expect-error
without proper checks can cause runtime issues, especially if scrollingElementRef
is not a valid React ref object. Removing null
from ref types is unsafe as React refs can be null before mounting or if the element is unmounted, potentially causing runtime errors.
// @ts-expect-error TODO | ||
// eslint-disable-next-line no-param-reassign | ||
scrollingElementRef.current = node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
The // @ts-expect-error
suppresses a type error without proper type checking. If scrollingElementRef
is not a valid React ref object with a current
property, this assignment could cause runtime errors. Consider adding proper type guards or using MutableRefObject
type.
// @ts-expect-error TODO | |
// eslint-disable-next-line no-param-reassign | |
scrollingElementRef.current = node; | |
if (scrollingElementRef && 'current' in scrollingElementRef) { | |
scrollingElementRef.current = node; | |
} |
@@ -21,7 +21,7 @@ export type Props = Common.Globals & | |||
closable & { | |||
readonly size?: Size; | |||
readonly children: React.ReactNode; | |||
readonly triggerRef?: React.RefObject<HTMLElement | null>; | |||
readonly triggerRef?: React.RefObject<HTMLElement>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
Removing null
from RefObject
and Ref
types is unsafe as React refs can be null before the component mounts or if the referenced element is unmounted. This can lead to runtime errors when accessing these refs.
readonly triggerRef?: React.RefObject<HTMLElement>; | |
readonly triggerRef?: React.RefObject<HTMLElement | null>; |
@@ -21,7 +21,7 @@ export type Props = Common.Globals & | |||
closable & { | |||
readonly size?: Size; | |||
readonly children: React.ReactNode; | |||
readonly triggerRef?: React.RefObject<HTMLElement | null>; | |||
readonly triggerRef?: React.RefObject<HTMLElement>; | |||
readonly lockScrolling?: boolean; | |||
readonly scrollingElementRef?: React.Ref<HTMLElement | null>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
The scrollingElementRef
should allow for null values as the ref might not be initialized immediately or could become null during component lifecycle.
readonly scrollingElementRef?: React.Ref<HTMLElement | null>; | |
readonly scrollingElementRef?: React.Ref<HTMLElement | null>; |
b21d412
to
3ec7c79
Compare
Storybook staging is available at https://kiwicom-orbit-sarka-react-upgrade-fix.surge.sh Playroom staging is available at https://kiwicom-orbit-sarka-react-upgrade-fix.surge.sh/playroom |
40890ec
to
549c74f
Compare
549c74f
to
9699cd9
Compare
This Pull Request meets the following criteria:
For new components:
d.ts
files and are exported inindex.d.ts
✨
Description by Callstackai
This PR updates type definitions to ensure compatibility with React 18.3, specifically refining the types of refs used in various components.
Diagrams of code changes
Files Changed