Fix crash when evaluating builder preview specific code in prod apps

This commit is contained in:
Andrew Kingston 2021-08-19 16:04:15 +01:00
parent 3020b59d86
commit 643952e119
1 changed files with 5 additions and 0 deletions

View File

@ -61,6 +61,11 @@ const createBuilderStore = () => {
} }
const writableStore = writable(initialState) const writableStore = writable(initialState)
const derivedStore = derived(writableStore, $state => { const derivedStore = derived(writableStore, $state => {
// Avoid any of this logic if we aren't in the builder preview
if (!writableStore.inBuilder) {
return $state
}
// Derive the selected component instance and definition // Derive the selected component instance and definition
const { layout, screen, previewType, selectedComponentId } = $state const { layout, screen, previewType, selectedComponentId } = $state
const asset = previewType === "layout" ? layout : screen const asset = previewType === "layout" ? layout : screen