mirror of
https://github.com/maputnik/editor.git
synced 2025-12-19 20:50:01 +00:00
Update sources if they change
This commit is contained in:
@@ -24,16 +24,26 @@ class AddModal extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
|
||||
console.log('sources', this.props.sources)
|
||||
this.state = {
|
||||
type: 'fill',
|
||||
id: '',
|
||||
//source: Object.keys(this.props.sources)[0],
|
||||
//'source-layer': this.props.sources[0][0]
|
||||
}
|
||||
|
||||
if(props.sources.length > 0) {
|
||||
this.state.source = Object.keys(this.props.sources)[0]
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const sourceIds = Object.keys(nextProps.sources)
|
||||
if(!this.state.source && sourceIds.length > 0) {
|
||||
this.setState({
|
||||
source: sourceIds[0],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
return <Modal
|
||||
isOpen={this.props.isOpen}
|
||||
|
||||
Reference in New Issue
Block a user