@@ -11,7 +11,7 @@ import React from 'react';
11
11
import shortId from 'shortid' ;
12
12
import qs from 'qs' ;
13
13
import SSR from 'utils/SSR' ;
14
- import { config } from 'topcoder-react-utils' ;
14
+ import { config , isomorphy } from 'topcoder-react-utils' ;
15
15
import { connect } from 'react-redux' ;
16
16
17
17
// Setting those to infinity to disable maxage and auto refresh
@@ -156,6 +156,10 @@ class ContentfulLoader extends React.Component {
156
156
const b = this . loadContentOnMount ( entryIds , 'entries' , timeLimit ) ;
157
157
const c = this . loadQueriesOnMount ( assetQueries , 'assets' , timeLimit ) ;
158
158
const d = this . loadQueriesOnMount ( entryQueries , 'entries' , timeLimit ) ;
159
+ if ( isomorphy . isClientSide ( ) ) {
160
+ this . handleResize = _ . throttle ( this . handleResize . bind ( this ) , 250 ) ;
161
+ window . addEventListener ( 'resize' , this . handleResize ) ;
162
+ }
159
163
return Promise . all ( [ ...a , ...b , ...c , ...d ] )
160
164
. then ( ( ) => new Promise ( resolve => setTimeout ( ( ) => resolve ( ) , 100 ) ) ) ;
161
165
}
@@ -208,6 +212,18 @@ class ContentfulLoader extends React.Component {
208
212
const ids = toArray ( entryQueries ) . map ( query => queryToMd5 ( query ) ) ;
209
213
ids . forEach ( id => freeQuery ( id , 'entries' , preview , spaceName , environment ) ) ;
210
214
}
215
+
216
+ if ( isomorphy . isClientSide ( ) ) {
217
+ window . removeEventListener ( 'resize' , this . handleResize ) ;
218
+ }
219
+ }
220
+
221
+ /**
222
+ * On window resize trigger render
223
+ * for this and all child componets
224
+ */
225
+ handleResize ( ) {
226
+ this . forceUpdate ( ) ;
211
227
}
212
228
213
229
/**
0 commit comments