mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-28 05:05:48 +08:00
refactor: Remove useless code (#29931)
* refactor: Remove useless code * rm useless code
This commit is contained in:
parent
077443696b
commit
7fe8f0469c
@ -1,5 +1,4 @@
|
||||
import * as React from 'react';
|
||||
import debounce from 'lodash/debounce';
|
||||
import SlickCarousel, { Settings } from '@ant-design/react-slick';
|
||||
import classNames from 'classnames';
|
||||
import { ConfigContext } from '../config-provider';
|
||||
@ -51,35 +50,6 @@ const Carousel = React.forwardRef<CarouselRef, CarouselProps>(
|
||||
[slickRef.current],
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
const func = () => {
|
||||
// Fix https://github.com/ant-design/ant-design/issues/2550
|
||||
const { autoplay } = props;
|
||||
if (
|
||||
autoplay &&
|
||||
slickRef.current &&
|
||||
slickRef.current.innerSlider &&
|
||||
slickRef.current.innerSlider.autoPlay
|
||||
) {
|
||||
slickRef.current.innerSlider.autoPlay();
|
||||
}
|
||||
};
|
||||
|
||||
const onWindowResized = debounce(func, 500, {
|
||||
leading: false,
|
||||
});
|
||||
|
||||
if (props.autoplay) {
|
||||
window.addEventListener('resize', onWindowResized);
|
||||
}
|
||||
return () => {
|
||||
if (props.autoplay) {
|
||||
window.removeEventListener('resize', onWindowResized);
|
||||
(onWindowResized as any).cancel();
|
||||
}
|
||||
};
|
||||
}, [slickRef.current, props.autoplay]);
|
||||
|
||||
const prevCount = React.useRef(React.Children.count(props.children));
|
||||
|
||||
React.useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user