Skip to content

Commit

Permalink
fix(playground) app shouldn’t crash while user is typing (#9316)
Browse files Browse the repository at this point in the history
* Update configuration.js
  • Loading branch information
chrisgervang authored Jan 4, 2025
1 parent 18c4ae4 commit 9589969
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/playground/src/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// This configuration object determines which deck.gl classes are accessible in Playground

import {MapView, FirstPersonView, OrbitView, OrthographicView} from '@deck.gl/core';
import {MapView, FirstPersonView, OrbitView, OrthographicView, View, Layer} from '@deck.gl/core';
import * as Layers from '@deck.gl/layers';
import * as AggregationLayers from '@deck.gl/aggregation-layers';
import * as GeoLayers from '@deck.gl/geo-layers';
Expand Down Expand Up @@ -57,5 +57,19 @@ export default {
constants: {
Tiles3DLoader,
CesiumIonLoader
},

postProcessConvertedJson: json => {
// Filter out invalid props. Typically, props will be invalid while the user is typing.
if (json.layers) {
json.layers = json.layers.filter(layer => layer instanceof Layer);
}
if (json.widgets) {
json.widgets = json.widgets.filter(widget => typeof widget.onAdd === 'function');
}
if (json.views && !(json.views instanceof View)) {
json.views = json.views.filter(view => view instanceof View);
}
return json;
}
};

0 comments on commit 9589969

Please sign in to comment.