From 9095189bcf99fc4557d38024a4465cc26a15c9c6 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 12 Aug 2019 15:10:35 +0800 Subject: [PATCH] :white_check_mark: fix Carousel test case --- components/carousel/__tests__/index.test.js | 5 +++++ components/carousel/index.tsx | 3 +-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/carousel/__tests__/index.test.js b/components/carousel/__tests__/index.test.js index e1e27fadbc..e5a7407b08 100644 --- a/components/carousel/__tests__/index.test.js +++ b/components/carousel/__tests__/index.test.js @@ -116,6 +116,11 @@ describe('Carousel', () => { }); it('should keep initialSlide', () => { + // react unsafe lifecycle don't works in React 15 + // https://github.com/akiran/react-slick/commit/97988e897750e1d8f7b10a86b655f50d75d38298 + if (process.env.REACT === '15') { + return; + } const wrapper = mount(); wrapper.setProps({ children: [
,
,
], diff --git a/components/carousel/index.tsx b/components/carousel/index.tsx index 37fd345367..ed3e0f7a64 100644 --- a/components/carousel/index.tsx +++ b/components/carousel/index.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import debounce from 'lodash/debounce'; import { Settings } from 'react-slick'; -import { polyfill } from 'react-lifecycles-compat'; import { ConfigConsumer, ConfigConsumerProps } from '../config-provider'; import warning from '../_util/warning'; @@ -22,7 +21,7 @@ if (typeof window !== 'undefined') { // make sure matchMedia polyfill run before require('react-slick') // Fix https://github.com/ant-design/ant-design/issues/6560 // Fix https://github.com/ant-design/ant-design/issues/3308 -const SlickCarousel = polyfill(require('react-slick').default); +const SlickCarousel = require('react-slick').default; export type CarouselEffect = 'scrollx' | 'fade'; export type DotPosition = 'top' | 'bottom' | 'left' | 'right'; diff --git a/package.json b/package.json index 34a11d7eba..2ec6123a97 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "rc-util": "^4.6.0", "react-lazy-load": "^3.0.13", "react-lifecycles-compat": "^3.0.4", - "react-slick": "~0.25.0", + "react-slick": "~0.25.2", "resize-observer-polyfill": "^1.5.1", "shallowequal": "^1.1.0", "warning": "~4.0.3"