File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -56,7 +56,10 @@ export class Frame extends Component {
5656 componentWillUnmount ( ) {
5757 this . _isMounted = false ;
5858
59- this . nodeRef . current . removeEventListener ( 'load' , this . handleLoad ) ;
59+ this . nodeRef . current . removeEventListener (
60+ 'DOMContentLoaded' ,
61+ this . handleLoad
62+ ) ;
6063 }
6164
6265 getDoc ( ) {
@@ -83,12 +86,19 @@ export class Frame extends Component {
8386 } ;
8487
8588 handleLoad = ( ) => {
89+ clearInterval ( this . loadCheck ) ;
8690 // Bail update as some browsers will trigger on both DOMContentLoaded & onLoad ala firefox
8791 if ( ! this . state . iframeLoaded ) {
8892 this . setState ( { iframeLoaded : true } ) ;
8993 }
9094 } ;
9195
96+ // In certain situations on a cold cache DOMContentLoaded never gets called
97+ // fallback to an interval to check if that's the case
98+ loadCheck = setInterval ( function loadCheckCallback ( ) {
99+ this . handleLoad ( ) ;
100+ } , 500 ) ;
101+
92102 renderFrameContents ( ) {
93103 if ( ! this . _isMounted ) {
94104 return null ;
@@ -135,6 +145,7 @@ export class Frame extends Component {
135145 delete props . contentDidMount ;
136146 delete props . contentDidUpdate ;
137147 delete props . forwardedRef ;
148+
138149 return (
139150 < iframe { ...props } ref = { this . setRef } onLoad = { this . handleLoad } >
140151 { this . state . iframeLoaded && this . renderFrameContents ( ) }
Original file line number Diff line number Diff line change @@ -24,5 +24,10 @@ module.exports = {
2424 loaders : [
2525 { test : / \. j s ( x | ) / , loaders : [ 'babel-loader' ] , exclude : / n o d e _ m o d u l e s / }
2626 ]
27+ } ,
28+ devServer : {
29+ headers : {
30+ 'Cache-Control' : 'max-age=10'
31+ }
2732 }
2833} ;
You can’t perform that action at this time.
0 commit comments