Skip to content

Commit c7e9a8e

Browse files
author
David Emory
committed
refactor(form): Refactor props definition in mode-selector
Use defaultProps to set default values for label, showLabel. Update propTypes definition.
1 parent 118226b commit c7e9a8e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/components/form/mode-selector.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ import { setMode } from '../../actions/form'
66

77
class ModeSelector extends Component {
88
static propTypes = {
9-
location: PropTypes.object,
9+
config: PropTypes.object,
1010
label: PropTypes.string,
11-
setLocation: PropTypes.func,
12-
showLabel: PropTypes.boolean,
13-
type: PropTypes.string // replace with locationType?
11+
mode: PropTypes.string,
12+
setMode: PropTypes.func,
13+
showLabel: PropTypes.boolean
14+
}
15+
16+
static defaultProps = {
17+
label: 'Mode',
18+
showLabel: true
1419
}
1520

1621
_onChange = (evt) => {
@@ -29,9 +34,7 @@ class ModeSelector extends Component {
2934
}
3035

3136
render () {
32-
const { config, mode } = this.props
33-
const label = this.props.label || 'Mode:'
34-
const showLabel = this.props.showLabel === undefined ? true : this.props.showLabel
37+
const { config, mode, label, showLabel } = this.props
3538

3639
return (
3740
<form>

0 commit comments

Comments
 (0)