Use defaultProps instead of _.get()

pull/10616/head
Andrew Watkins 2017-08-22 13:05:24 -07:00
parent 987d353a84
commit 19202e8620
1 changed files with 15 additions and 9 deletions

View File

@ -1,23 +1,16 @@
import React, {PropTypes} from 'react'
import _ from 'lodash'
import OptIn from 'shared/components/OptIn'
const AxesOptions = ({
axes,
axes: {y: {bounds, label, prefix, suffix, base, defaultYLabel}},
onSetBase,
onSetLabel,
onSetPrefixSuffix,
onSetYAxisBoundMin,
onSetYAxisBoundMax,
}) => {
const min = _.get(axes, ['y', 'bounds', '0'], '')
const max = _.get(axes, ['y', 'bounds', '1'], '')
const label = _.get(axes, ['y', 'label'], '')
const defaultYLabel = _.get(axes, ['y', 'defaultYLabel'], '')
const prefix = _.get(axes, ['y', 'prefix'], '')
const suffix = _.get(axes, ['y', 'suffix'], '')
const base = _.get(axes, ['y', 'base'], '10')
const [min, max] = bounds
return (
<div className="display-options--cell">
@ -103,6 +96,19 @@ const AxesOptions = ({
const {arrayOf, func, shape, string} = PropTypes
AxesOptions.defaultProps = {
axes: {
y: {
bounds: ['', ''],
prefix: '',
suffix: '',
base: '10',
scale: 'linear',
defaultYLabel: '',
},
},
}
AxesOptions.propTypes = {
onSetPrefixSuffix: func.isRequired,
onSetYAxisBoundMin: func.isRequired,