diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 11:12:28 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2019-05-02 22:07:54 +0900 |
commit | e69497fab457df486b2a7068bdd0283505461f8b (patch) | |
tree | f1cb4111bae89160d4238df9057493a50acacc39 /src/settings/components/form/KeymapsForm.tsx | |
parent | c059bf8be3b302173f2cab0d22a434aea4a6e0bd (diff) |
Types src/settings
Diffstat (limited to 'src/settings/components/form/KeymapsForm.tsx')
-rw-r--r-- | src/settings/components/form/KeymapsForm.tsx | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/settings/components/form/KeymapsForm.tsx b/src/settings/components/form/KeymapsForm.tsx index 01acf61..ab44464 100644 --- a/src/settings/components/form/KeymapsForm.tsx +++ b/src/settings/components/form/KeymapsForm.tsx @@ -1,10 +1,22 @@ import './KeymapsForm.scss'; import React from 'react'; -import PropTypes from 'prop-types'; import Input from '../ui/Input'; import keymaps from '../../keymaps'; -class KeymapsForm extends React.Component { +type Value = {[key: string]: string}; + +interface Props{ + value: Value; + onChange: (e: Value) => void; + onBlur: () => void; +} + +class KeymapsForm extends React.Component<Props> { + public static defaultProps: Props = { + value: {}, + onChange: () => {}, + onBlur: () => {}, + } render() { return <div className='form-keymaps-form'> @@ -19,7 +31,7 @@ class KeymapsForm extends React.Component { return <Input type='text' id={name} name={name} key={name} label={label} value={value} - onChange={this.bindValue.bind(this)} + onValueChange={this.bindValue.bind(this)} onBlur={this.props.onBlur} />; }) @@ -30,22 +42,12 @@ class KeymapsForm extends React.Component { </div>; } - bindValue(e) { + bindValue(name: string, value: string) { let next = { ...this.props.value }; - next[e.target.name] = e.target.value; + next[name] = value; this.props.onChange(next); } } -KeymapsForm.propTypes = { - value: PropTypes.objectOf(PropTypes.string), - onChange: PropTypes.func, -}; - -KeymapsForm.defaultProps = { - value: {}, - onChange: () => {}, -}; - export default KeymapsForm; |