mirror of
https://github.com/a-nyx/maputnik-with-pmtiles.git
synced 2024-12-28 17:21:18 +01:00
Fix many React warnings
This commit is contained in:
parent
ec9fc8f6ad
commit
766a3e387e
6 changed files with 23 additions and 23 deletions
|
@ -76,6 +76,7 @@ export default class SpecField extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
return <SelectInput
|
return <SelectInput
|
||||||
{...commonProps}
|
{...commonProps}
|
||||||
|
value={this.props.value || this.props.fieldSpec.default}
|
||||||
options={options}
|
options={options}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ export default class ZoomSpecField extends React.Component {
|
||||||
<DocLabel
|
<DocLabel
|
||||||
label={<FunctionIcon />}
|
label={<FunctionIcon />}
|
||||||
cursorTargetStyle={{ cursor: 'pointer' }}
|
cursorTargetStyle={{ cursor: 'pointer' }}
|
||||||
doc="Turn property into a zoom function to enable a map feature to change with map's zoom level."
|
doc={"Turn property into a zoom function to enable a map feature to change with map's zoom level."}
|
||||||
/>
|
/>
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,9 +75,8 @@ export default class CombiningFilterEditor extends React.Component {
|
||||||
let filters = filter.slice(1)
|
let filters = filter.slice(1)
|
||||||
|
|
||||||
const editorBlocks = filters.map((f, idx) => {
|
const editorBlocks = filters.map((f, idx) => {
|
||||||
return <FilterEditorBlock onDelete={this.deleteFilterItem.bind(this, idx)}>
|
return <FilterEditorBlock key={idx} onDelete={this.deleteFilterItem.bind(this, idx)}>
|
||||||
<SingleFilterEditor
|
<SingleFilterEditor
|
||||||
key={idx}
|
|
||||||
properties={this.props.properties}
|
properties={this.props.properties}
|
||||||
filter={f}
|
filter={f}
|
||||||
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
|
onChange={this.onFilterPartChanged.bind(this, idx + 1)}
|
||||||
|
|
|
@ -5,24 +5,19 @@ class StringInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
value: React.PropTypes.string,
|
value: React.PropTypes.string,
|
||||||
style: React.PropTypes.object,
|
style: React.PropTypes.object,
|
||||||
default: React.PropTypes.number,
|
default: React.PropTypes.string,
|
||||||
onChange: React.PropTypes.func,
|
onChange: React.PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
value: props.value
|
value: props.value || ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeValue(newValue) {
|
|
||||||
//TODO: In feature we can try to do validation here as well
|
|
||||||
this.setState({ value: newValue })
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.setState({ value: nextProps.value })
|
this.setState({ value: nextProps.value || '' })
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -33,8 +28,10 @@ class StringInput extends React.Component {
|
||||||
}}
|
}}
|
||||||
value={this.state.value}
|
value={this.state.value}
|
||||||
placeholder={this.props.default}
|
placeholder={this.props.default}
|
||||||
onChange={e => this.changeValue(e.target.value)}
|
onChange={e => this.setState({ value: e.target.value })}
|
||||||
onBlur={() => this.props.onChange(this.state.value)}
|
onBlur={() => {
|
||||||
|
if(this.state.value) this.props.onChange(this.state.value)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,12 +16,6 @@ const Panel = (props) => {
|
||||||
}}>{props.children}</div>
|
}}>{props.children}</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderFeature(feature) {
|
|
||||||
return <div>
|
|
||||||
<Panel>{feature.layer['source-layer']}</Panel>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
function groupFeaturesBySourceLayer(features) {
|
function groupFeaturesBySourceLayer(features) {
|
||||||
const sources = {}
|
const sources = {}
|
||||||
features.forEach(feature => {
|
features.forEach(feature => {
|
||||||
|
@ -52,7 +46,7 @@ class FeatureLayerPopup extends React.Component {
|
||||||
{feature.layer.id}
|
{feature.layer.id}
|
||||||
</label>
|
</label>
|
||||||
})
|
})
|
||||||
return <div>
|
return <div key={vectorLayerId}>
|
||||||
<Panel>{vectorLayerId}</Panel>
|
<Panel>{vectorLayerId}</Panel>
|
||||||
{layers}
|
{layers}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,11 +5,20 @@ import StringInput from '../inputs/StringInput'
|
||||||
import colors from '../../config/colors'
|
import colors from '../../config/colors'
|
||||||
import { margins, fontSizes } from '../../config/scales'
|
import { margins, fontSizes } from '../../config/scales'
|
||||||
|
|
||||||
|
function displayValue(value) {
|
||||||
|
if (typeof value === 'undefined' || value === null) return value;
|
||||||
|
if (value instanceof Date) return value.toLocaleString();
|
||||||
|
if (typeof value === 'object' ||
|
||||||
|
typeof value === 'number' ||
|
||||||
|
typeof value === 'string') return value.toString();
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
function renderProperties(feature) {
|
function renderProperties(feature) {
|
||||||
return Object.keys(feature.properties).map(propertyName => {
|
return Object.keys(feature.properties).map(propertyName => {
|
||||||
const property = feature.properties[propertyName]
|
const property = feature.properties[propertyName]
|
||||||
return <InputBlock label={propertyName} style={{marginTop: 0, marginBottom: 0}}>
|
return <InputBlock key={propertyName} label={propertyName} style={{marginTop: 0, marginBottom: 0}}>
|
||||||
<StringInput value={property} style={{backgroundColor: 'transparent'}}/>
|
<StringInput value={displayValue(property)} style={{backgroundColor: 'transparent'}}/>
|
||||||
</InputBlock>
|
</InputBlock>
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -24,7 +33,7 @@ const Panel = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderFeature(feature) {
|
function renderFeature(feature) {
|
||||||
return <div>
|
return <div key={feature.id}>
|
||||||
<Panel>{feature.layer['source-layer']}</Panel>
|
<Panel>{feature.layer['source-layer']}</Panel>
|
||||||
{renderProperties(feature)}
|
{renderProperties(feature)}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue