We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7509467 commit 9773472Copy full SHA for 9773472
website/src/components/Stackblitz/index.tsx
@@ -50,10 +50,14 @@ function getStackblitzEl(projectId: string, exampleId?: string) {
50
const embedPromise = embedFn(el, projectId, opts);
51
52
embedPromise.then(async (p) => {
53
- try {
54
- await p.preview.getUrl();
55
- if (exampleId) p.preview.setUrl(`/${exampleId || ''}`);
56
- } catch (e) {}
+ // Set URL fails, probably because the preview is not loaded yet
+ // so we need to poll until it is loaded
+ const interval = setInterval(async () => {
+ try {
57
+ await p.preview.setUrl(`/${exampleId || ''}`);
58
+ clearInterval(interval);
59
+ } catch (e) {}
60
+ }, 300);
61
});
62
63
cache[projectId] = elParent;
0 commit comments