Skip to content

Commit

Permalink
fix: fix Button findDOMNode error (#48830)
Browse files Browse the repository at this point in the history
* fix: fix Button findDOMNode error

* test: update test case

* fix: optimize code

* Update components/_util/wave/WaveEffect.tsx

Co-authored-by: lijianan <574980606@qq.com>
Signed-off-by: Wanpan <wanpan96@163.com>

* fix: optimize code

* fix: update test

* fix: update test

---------

Signed-off-by: Wanpan <wanpan96@163.com>
Co-authored-by: lijianan <574980606@qq.com>
  • Loading branch information
wanpan11 and li-jia-nan committed May 10, 2024
1 parent cf6e9c8 commit c3cf0de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions components/_util/__tests__/wave.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('Wave component', () => {
}

it('work', async () => {
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container, unmount } = render(
<Wave>
<button type="button">button</button>
Expand All @@ -95,6 +96,8 @@ describe('Wave component', () => {

expect(document.querySelector('.ant-wave')).toBeFalsy();

expect(errorSpy).not.toHaveBeenCalled();

unmount();
});

Expand Down
7 changes: 4 additions & 3 deletions components/_util/wave/WaveEffect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import classNames from 'classnames';
import CSSMotion from 'rc-motion';
import raf from 'rc-util/lib/raf';
import { render, unmount } from 'rc-util/lib/React/render';
import { composeRef } from 'rc-util/es/ref';

import { TARGET_CLS } from './interface';
import type { ShowWaveEffect } from './interface';
Expand All @@ -20,7 +21,7 @@ export interface WaveEffectProps {

const WaveEffect: React.FC<WaveEffectProps> = (props) => {
const { className, target, component } = props;
const divRef = React.useRef<HTMLDivElement>(null);
const divRef = React.useRef<HTMLDivElement | null>(null);

const [color, setWaveColor] = React.useState<string | null>(null);
const [borderRadius, setBorderRadius] = React.useState<number[]>([]);
Expand Down Expand Up @@ -125,9 +126,9 @@ const WaveEffect: React.FC<WaveEffectProps> = (props) => {
return false;
}}
>
{({ className: motionClassName }) => (
{({ className: motionClassName }, ref) => (
<div
ref={divRef}
ref={composeRef(divRef, ref)}
className={classNames(
className,
{
Expand Down

0 comments on commit c3cf0de

Please sign in to comment.