refactor: Remove useless code (#29931)

* refactor: Remove useless code

* rm useless code
This commit is contained in:
二货机器人 2021-03-29 11:02:58 +08:00 committed by GitHub
parent 077443696b
commit 7fe8f0469c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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(() => {