@@ -57,7 +57,7 @@ type State = {
5757
5858export default class Preview extends React . PureComponent < Props , State > {
5959 initialPath : string ;
60- frames : Array < HTMLFrameElement > ;
60+ frames : Set < HTMLIFrameElement > ;
6161
6262 constructor ( props : Props ) {
6363 super ( props ) ;
@@ -78,7 +78,7 @@ export default class Preview extends React.PureComponent<Props, State> {
7878 // from the query params, or the iframe will continue to be re-rendered
7979 // when the user navigates the iframe app, which shows the loading screen
8080 this . initialPath = props . initialPath ;
81- this . frames = [ ] ;
81+ this . frames = new Set ( ) ;
8282 }
8383
8484 static defaultProps = {
@@ -161,14 +161,15 @@ export default class Preview extends React.PureComponent<Props, State> {
161161 } ;
162162
163163 sendMessage = ( message : Object ) => {
164- this . frames . forEach ( frame => {
164+ Array . from ( this . frames ) . forEach ( frame => {
165165 frame . postMessage ( message , frameUrl ( this . props . sandboxId ) ) ;
166166 } ) ;
167167 } ;
168168
169169 handleMessage = ( e : MessageEvent | { data : Object | string } ) => {
170170 if ( e . data === 'Ready!' ) {
171- this . frames . push ( e . source ) ;
171+ this . frames . add ( e . source ) ;
172+ console . log ( this . frames ) ; // eslint-disable-line
172173 this . setState ( {
173174 frameInitialized : true ,
174175 } ) ;
@@ -274,11 +275,7 @@ export default class Preview extends React.PureComponent<Props, State> {
274275 handleRefresh = ( ) => {
275276 const { history, historyPosition } = this . state ;
276277
277- document . getElementById ( 'sandbox' ) . src = '' ;
278-
279- setTimeout ( ( ) => {
280- document . getElementById ( 'sandbox' ) . src = history [ historyPosition ] ;
281- } , 100 ) ;
278+ document . getElementById ( 'sandbox' ) . src = history [ historyPosition ] ;
282279
283280 this . setState ( {
284281 urlInAddressBar : history [ historyPosition ] ,
0 commit comments