diff options
Diffstat (limited to 'src/settings')
-rw-r--r-- | src/settings/components/form/BlacklistForm.jsx | 11 | ||||
-rw-r--r-- | src/settings/components/form/KeymapsForm.jsx | 10 | ||||
-rw-r--r-- | src/settings/components/form/SearchForm.jsx | 6 |
3 files changed, 13 insertions, 14 deletions
diff --git a/src/settings/components/form/BlacklistForm.jsx b/src/settings/components/form/BlacklistForm.jsx index 7dad9ee..cee04bd 100644 --- a/src/settings/components/form/BlacklistForm.jsx +++ b/src/settings/components/form/BlacklistForm.jsx @@ -7,14 +7,9 @@ import PropTypes from 'prop-types'; class BlacklistForm extends React.Component { render() { - let value = this.props.value; - if (!value) { - value = []; - } - return <div className='form-blacklist-form'> { - value.map((url, index) => { + this.props.value.map((url, index) => { return <div key={index} className='form-blacklist-form-row'> <input data-index={index} type='text' name='url' className='column-url' value={url} @@ -55,4 +50,8 @@ BlacklistForm.propTypes = { onChange: PropTypes.func, }; +BlacklistForm.defaultProps = { + value: [], +}; + export default BlacklistForm; diff --git a/src/settings/components/form/KeymapsForm.jsx b/src/settings/components/form/KeymapsForm.jsx index f5444fc..26a22d7 100644 --- a/src/settings/components/form/KeymapsForm.jsx +++ b/src/settings/components/form/KeymapsForm.jsx @@ -7,10 +7,6 @@ import keymaps from '../../keymaps'; class KeymapsForm extends React.Component { render() { - let values = this.props.value; - if (!values) { - values = {}; - } return <div className='form-keymaps-form'> { keymaps.fields.map((group, index) => { @@ -19,7 +15,7 @@ class KeymapsForm extends React.Component { group.map((field) => { let name = field[0]; let label = field[1]; - let value = values[name]; + let value = this.props.value[name] || ''; return <Input type='text' id={name} name={name} key={name} label={label} value={value} @@ -50,4 +46,8 @@ KeymapsForm.propTypes = { onChange: PropTypes.func, }; +KeymapsForm.defaultProps = { + value: {}, +}; + export default KeymapsForm; diff --git a/src/settings/components/form/SearchForm.jsx b/src/settings/components/form/SearchForm.jsx index 718cca1..2e070fc 100644 --- a/src/settings/components/form/SearchForm.jsx +++ b/src/settings/components/form/SearchForm.jsx @@ -8,9 +8,6 @@ class SearchForm extends React.Component { render() { let value = this.props.value; - if (!value) { - value = { default: '', engines: []}; - } if (!value.engines) { value.engines = []; } @@ -82,7 +79,10 @@ SearchForm.propTypes = { engines: PropTypes.arrayOf(PropTypes.arrayOf(PropTypes.string)), }), onChange: PropTypes.func, +}; +SearchForm.defaultProps = { + value: { default: '', engines: []}, }; export default SearchForm; |