Fix many React warnings

This commit is contained in:
Lukas Martinelli
2017-01-10 09:38:27 +01:00
parent ec9fc8f6ad
commit 766a3e387e
6 changed files with 23 additions and 23 deletions
+12 -3
View File
@@ -5,11 +5,20 @@ import StringInput from '../inputs/StringInput'
import colors from '../../config/colors'
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) {
return Object.keys(feature.properties).map(propertyName => {
const property = feature.properties[propertyName]
return <InputBlock label={propertyName} style={{marginTop: 0, marginBottom: 0}}>
<StringInput value={property} style={{backgroundColor: 'transparent'}}/>
return <InputBlock key={propertyName} label={propertyName} style={{marginTop: 0, marginBottom: 0}}>
<StringInput value={displayValue(property)} style={{backgroundColor: 'transparent'}}/>
</InputBlock>
})
}
@@ -24,7 +33,7 @@ const Panel = (props) => {
}
function renderFeature(feature) {
return <div>
return <div key={feature.id}>
<Panel>{feature.layer['source-layer']}</Panel>
{renderProperties(feature)}
</div>