-
-
Notifications
You must be signed in to change notification settings - Fork 478
refactor: Upgrade utils and replace useMergedState #1162
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type { AlignType, BuildInPlacements } from '@rc-component/trigger/lib/interface'; | ||
import cls from 'classnames'; | ||
import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect'; | ||
import useMergedState from '@rc-component/util/lib/hooks/useMergedState'; | ||
import useControlledState from '@rc-component/util/lib/hooks/useControlledState'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
import isMobile from '@rc-component/util/lib/isMobile'; | ||
import { useComposeRef } from '@rc-component/util/lib/ref'; | ||
import { getDOM } from '@rc-component/util/lib/Dom/findDOMNode'; | ||
|
@@ -383,10 +383,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref) | |
setRendered(true); | ||
}, []); | ||
|
||
const [innerOpen, setInnerOpen] = useMergedState<boolean>(false, { | ||
defaultValue: defaultOpen, | ||
value: open, | ||
}); | ||
const [innerOpen, setInnerOpen] = useControlledState<boolean>(defaultOpen || false, open); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在原本 useMergedState 的使用中 defaultOpen 的使用优先于默认的 false |
||
|
||
let mergedOpen = rendered ? innerOpen : false; | ||
|
||
|
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.
This is good to upgrade to the latest version of
@rc-component/util
. However, ensure that all the changes in the new version are compatible with the current implementation and that all functionalities are working as expected.