mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 18:51:15 +01:00
Call fetchSources after component mount.
This commit is contained in:
parent
b5dc04bb4f
commit
63ac707415
1 changed files with 3 additions and 2 deletions
|
@ -69,10 +69,10 @@ export default class App extends React.Component {
|
|||
this.layerWatcher = new LayerWatcher({
|
||||
onVectorLayersChange: v => this.setState({ vectorLayers: v })
|
||||
})
|
||||
this.fetchSources();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchSources();
|
||||
Mousetrap.bind(['ctrl+z'], this.onUndo.bind(this));
|
||||
Mousetrap.bind(['ctrl+y'], this.onRedo.bind(this));
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ export default class App extends React.Component {
|
|||
}
|
||||
|
||||
fetchSources() {
|
||||
const sourceList = {...this.state.sources};
|
||||
const sourceList = {};
|
||||
|
||||
for(let [key, val] of Object.entries(this.state.mapStyle.sources)) {
|
||||
sourceList[key] = sourceList[key] || [];
|
||||
|
@ -197,6 +197,7 @@ export default class App extends React.Component {
|
|||
return response.json();
|
||||
})
|
||||
.then((json) => {
|
||||
// Create new objects before setState
|
||||
const sourceList = {...this.state.sources};
|
||||
sourceList[key] = [];
|
||||
|
||||
|
|
Loading…
Reference in a new issue