Skip to content

Commit a25dc63

Browse files
author
Ives van Hoorne
committed
Add nullcheck
1 parent e13e471 commit a25dc63

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

packages/react-sandpack/src/components/SandpackProvider/SandpackProvider.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,26 @@ export default class SandpackProvider extends React.PureComponent<
108108
}
109109

110110
setupFrame = (el: HTMLIFrameElement) => {
111-
this.manager = new Manager(
112-
el,
113-
{
114-
files: generatePackageJSON(
115-
this.props.files,
116-
this.props.dependencies,
117-
this.props.entry
118-
),
119-
template: this.props.template,
120-
},
121-
{
122-
skipEval: this.props.skipEval,
123-
}
124-
);
111+
if (el) {
112+
this.manager = new Manager(
113+
el,
114+
{
115+
files: generatePackageJSON(
116+
this.props.files,
117+
this.props.dependencies,
118+
this.props.entry
119+
),
120+
template: this.props.template,
121+
},
122+
{
123+
skipEval: this.props.skipEval,
124+
}
125+
);
125126

126-
this.iframe = el;
127+
this.iframe = el;
127128

128-
this.setState({ iframe: el });
129+
this.setState({ iframe: el });
130+
}
129131
};
130132

131133
updateFiles = (files: IFiles) => {

0 commit comments

Comments
 (0)