File tree Expand file tree Collapse file tree 3 files changed +11
-17
lines changed Expand file tree Collapse file tree 3 files changed +11
-17
lines changed Original file line number Diff line number Diff line change 1
- // matchMedia polyfill for
2
- // https://github.com/WickyNilliams/enquire.js/issues/82
1
+ import React from 'react' ;
3
2
import debounce from 'lodash.debounce' ;
4
3
4
+ // matchMedia polyfill for
5
+ // https://github.com/WickyNilliams/enquire.js/issues/82
5
6
if ( typeof window !== 'undefined' ) {
6
7
const matchMediaPolyfill = ( mediaQuery : string ) : MediaQueryList => {
7
8
return {
@@ -15,9 +16,11 @@ if (typeof window !== 'undefined') {
15
16
} ;
16
17
window . matchMedia = window . matchMedia || matchMediaPolyfill ;
17
18
}
18
-
19
- import SlickCarousel from 'react-slick' ;
20
- import React from 'react' ;
19
+ // Use require over import (will be lifted up)
20
+ // make sure matchMedia polyfill run before require('react-slick')
21
+ // Fix https://github.com/ant-design/ant-design/issues/6560
22
+ // Fix https://github.com/ant-design/ant-design/issues/3308
23
+ const SlickCarousel = require ( 'react-slick' ) . default ;
21
24
22
25
export type CarouselEffect = 'scrollx' | 'fade' ;
23
26
// Carousel
Original file line number Diff line number Diff line change @@ -2,17 +2,6 @@ import { jsdom } from 'jsdom';
2
2
3
3
// fixed jsdom miss
4
4
if ( typeof window !== 'undefined' ) {
5
- const matchMediaPolyfill = function matchMediaPolyfill ( ) {
6
- return {
7
- matches : false ,
8
- addListener ( ) {
9
- } ,
10
- removeListener ( ) {
11
- } ,
12
- } ;
13
- } ;
14
- window . matchMedia = window . matchMedia || matchMediaPolyfill ;
15
-
16
5
const documentHTML = '<!doctype html><html><body><div id="root"></div></body></html>' ;
17
6
global . document = jsdom ( documentHTML ) ;
18
7
global . window = document . parentWindow ;
Original file line number Diff line number Diff line change @@ -90,4 +90,6 @@ declare module "*.json" {
90
90
export default value ;
91
91
}
92
92
93
- declare module "prop-types"
93
+ declare module "prop-types"
94
+
95
+ declare function require ( name : string ) : any ;
You can’t perform that action at this time.
0 commit comments