Skip to content
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

fix: 🐛 replace defaultProps with useDefaultProps #2380

Merged
merged 1 commit into from
Jul 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { getTransitionParams } from './utils/transition';
import useMutationObserver from '../_util/useMutationObserver';
import useWindowSize from '../_util/useWindowSize';
import { popupDefaultProps } from './defaultProps';
import useDefaultProps from '../hooks/useDefaultProps';

export interface PopupProps extends TdPopupProps {
// 是否触发展开收起动画,内部下拉式组件使用
Expand All @@ -34,7 +35,8 @@ export interface PopupRef {
getPortalElement: () => HTMLDivElement;
}

const Popup = forwardRef((props: PopupProps, ref: React.RefObject<PopupRef>) => {
const Popup = forwardRef<PopupRef, PopupProps>((originalProps, ref) => {
const props = useDefaultProps<PopupProps>(originalProps, popupDefaultProps);
const {
trigger,
content,
Expand Down Expand Up @@ -228,6 +230,5 @@ const Popup = forwardRef((props: PopupProps, ref: React.RefObject<PopupRef>) =>
});

Popup.displayName = 'Popup';
Popup.defaultProps = popupDefaultProps;

export default Popup;
Loading