mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
fix: FloatButton findDOMNode is deprecated in StrictMode. (#41833)
* fix: FloatButton findDOMNode is deprecated in StrictMode. * revert basic.tsx
This commit is contained in:
parent
7cd9b90b94
commit
0bcdce0cd7
@ -14,7 +14,9 @@ import useStyle from './style';
|
|||||||
|
|
||||||
export type { ScrollNumberProps } from './ScrollNumber';
|
export type { ScrollNumberProps } from './ScrollNumber';
|
||||||
|
|
||||||
type CompoundedComponent = React.FC<BadgeProps> & {
|
type CompoundedComponent = React.ForwardRefExoticComponent<
|
||||||
|
BadgeProps & React.RefAttributes<HTMLSpanElement>
|
||||||
|
> & {
|
||||||
Ribbon: typeof Ribbon;
|
Ribbon: typeof Ribbon;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,25 +42,26 @@ export interface BadgeProps {
|
|||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Badge: CompoundedComponent = ({
|
const InternalBadge: React.ForwardRefRenderFunction<HTMLSpanElement, BadgeProps> = (props, ref) => {
|
||||||
prefixCls: customizePrefixCls,
|
const {
|
||||||
scrollNumberPrefixCls: customizeScrollNumberPrefixCls,
|
prefixCls: customizePrefixCls,
|
||||||
children,
|
scrollNumberPrefixCls: customizeScrollNumberPrefixCls,
|
||||||
status,
|
children,
|
||||||
text,
|
status,
|
||||||
color,
|
text,
|
||||||
count = null,
|
color,
|
||||||
overflowCount = 99,
|
count = null,
|
||||||
dot = false,
|
overflowCount = 99,
|
||||||
size = 'default',
|
dot = false,
|
||||||
title,
|
size = 'default',
|
||||||
offset,
|
title,
|
||||||
style,
|
offset,
|
||||||
className,
|
style,
|
||||||
rootClassName,
|
className,
|
||||||
showZero = false,
|
rootClassName,
|
||||||
...restProps
|
showZero = false,
|
||||||
}) => {
|
...restProps
|
||||||
|
} = props;
|
||||||
const { getPrefixCls, direction } = React.useContext(ConfigContext);
|
const { getPrefixCls, direction } = React.useContext(ConfigContext);
|
||||||
const prefixCls = getPrefixCls('badge', customizePrefixCls);
|
const prefixCls = getPrefixCls('badge', customizePrefixCls);
|
||||||
|
|
||||||
@ -191,7 +194,7 @@ const Badge: CompoundedComponent = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return wrapSSR(
|
return wrapSSR(
|
||||||
<span {...restProps} className={badgeClassName}>
|
<span ref={ref} {...restProps} className={badgeClassName}>
|
||||||
{children}
|
{children}
|
||||||
<CSSMotion
|
<CSSMotion
|
||||||
visible={!isHidden}
|
visible={!isHidden}
|
||||||
@ -199,7 +202,7 @@ const Badge: CompoundedComponent = ({
|
|||||||
motionAppear={false}
|
motionAppear={false}
|
||||||
motionDeadline={1000}
|
motionDeadline={1000}
|
||||||
>
|
>
|
||||||
{({ className: motionClassName, ref }) => {
|
{({ className: motionClassName, ref: scrollNumberRef }) => {
|
||||||
const scrollNumberPrefixCls = getPrefixCls(
|
const scrollNumberPrefixCls = getPrefixCls(
|
||||||
'scroll-number',
|
'scroll-number',
|
||||||
customizeScrollNumberPrefixCls,
|
customizeScrollNumberPrefixCls,
|
||||||
@ -233,7 +236,7 @@ const Badge: CompoundedComponent = ({
|
|||||||
title={titleNode}
|
title={titleNode}
|
||||||
style={scrollNumberStyle}
|
style={scrollNumberStyle}
|
||||||
key="scrollNumber"
|
key="scrollNumber"
|
||||||
ref={ref}
|
ref={scrollNumberRef}
|
||||||
>
|
>
|
||||||
{displayNode}
|
{displayNode}
|
||||||
</ScrollNumber>
|
</ScrollNumber>
|
||||||
@ -245,6 +248,8 @@ const Badge: CompoundedComponent = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(InternalBadge) as CompoundedComponent;
|
||||||
|
|
||||||
Badge.Ribbon = Ribbon;
|
Badge.Ribbon = Ribbon;
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
Loading…
Reference in New Issue
Block a user