Skip to content

Commit 57e7f9a

Browse files
committed
Fix #5172
1 parent 549fd24 commit 57e7f9a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/shared/containers/ContentfulLoader.jsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import React from 'react';
1111
import shortId from 'shortid';
1212
import qs from 'qs';
1313
import SSR from 'utils/SSR';
14-
import { config } from 'topcoder-react-utils';
14+
import { config, isomorphy } from 'topcoder-react-utils';
1515
import { connect } from 'react-redux';
1616

1717
// Setting those to infinity to disable maxage and auto refresh
@@ -156,6 +156,10 @@ class ContentfulLoader extends React.Component {
156156
const b = this.loadContentOnMount(entryIds, 'entries', timeLimit);
157157
const c = this.loadQueriesOnMount(assetQueries, 'assets', timeLimit);
158158
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+
}
159163
return Promise.all([...a, ...b, ...c, ...d])
160164
.then(() => new Promise(resolve => setTimeout(() => resolve(), 100)));
161165
}
@@ -208,6 +212,18 @@ class ContentfulLoader extends React.Component {
208212
const ids = toArray(entryQueries).map(query => queryToMd5(query));
209213
ids.forEach(id => freeQuery(id, 'entries', preview, spaceName, environment));
210214
}
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();
211227
}
212228

213229
/**

0 commit comments

Comments
 (0)