Skip to content

Commit c8b3eab

Browse files
author
Ives van Hoorne
committed
Don't use Set in Preview
1 parent 0d5f27c commit c8b3eab

File tree

1 file changed

+6
-4
lines changed
  • src/app/components/sandbox/Preview

1 file changed

+6
-4
lines changed

src/app/components/sandbox/Preview/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type State = {
5757

5858
export default class Preview extends React.PureComponent<Props, State> {
5959
initialPath: string;
60-
frames: Set<HTMLIFrameElement>;
60+
frames: Array<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 = new Set();
81+
this.frames = [];
8282
}
8383

8484
static defaultProps = {
@@ -169,14 +169,16 @@ export default class Preview extends React.PureComponent<Props, State> {
169169
};
170170

171171
sendMessage = (message: Object) => {
172-
Array.from(this.frames).forEach(frame => {
172+
this.frames.forEach(frame => {
173173
frame.postMessage(message, frameUrl(this.props.sandboxId));
174174
});
175175
};
176176

177177
handleMessage = (e: MessageEvent | { data: Object | string }) => {
178178
if (e.data === 'Ready!') {
179-
this.frames.add(e.source);
179+
if (this.frames.indexOf(e.source) === -1) {
180+
this.frames.push(e.source);
181+
}
180182

181183
this.setState({
182184
frameInitialized: true,

0 commit comments

Comments
 (0)