From b8e9fb759eab5894ca2e2ad2eab341c2bf9a9caa Mon Sep 17 00:00:00 2001 From: valleykid Date: Fri, 19 Jan 2018 17:30:37 +0800 Subject: [PATCH] Fix a warning (#762) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add *bak in gitignore * 修复TableList表单验证误触发问题 * Remove props parent * Fix some warnings --- src/routes/List/TableList.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/src/routes/List/TableList.js b/src/routes/List/TableList.js index 8444af3f..8ee98e3e 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -11,11 +11,11 @@ const { Option } = Select; const getValue = obj => Object.keys(obj).map(key => obj[key]).join(','); const CreateForm = Form.create()((props) => { - const { modalVisible, addInputValue, parent, form } = props; + const { modalVisible, form, handleAdd, handleModalVisible } = props; const okHandle = () => { - form.validateFields((err/* , fieldsValue */) => { + form.validateFields((err, fieldsValue) => { if (err) return; - parent.handleAdd(); + handleAdd(fieldsValue); }); }; return ( @@ -23,8 +23,7 @@ const CreateForm = Form.create()((props) => { title="新建规则" visible={modalVisible} onOk={okHandle} - destroyOnClose - onCancel={() => parent.handleModalVisible()} + onCancel={() => handleModalVisible()} > { {form.getFieldDecorator('desc', { rules: [{ required: true, message: 'Please input some description...' }], })( - + )} @@ -48,7 +47,6 @@ const CreateForm = Form.create()((props) => { @Form.create() export default class TableList extends PureComponent { state = { - addInputValue: '', modalVisible: false, expandForm: false, selectedRows: [], @@ -167,17 +165,11 @@ export default class TableList extends PureComponent { }); } - handleAddInput = (e) => { - this.setState({ - addInputValue: e.target.value, - }); - } - - handleAdd = () => { + handleAdd = (fields) => { this.props.dispatch({ type: 'rule/add', payload: { - description: this.state.addInputValue, + description: fields.desc, }, }); @@ -301,7 +293,7 @@ export default class TableList extends PureComponent { render() { const { rule: { data }, loading } = this.props; - const { selectedRows, modalVisible, addInputValue } = this.state; + const { selectedRows, modalVisible } = this.state; const menu = ( @@ -313,7 +305,6 @@ export default class TableList extends PureComponent { const parentMethods = { handleAdd: this.handleAdd, handleModalVisible: this.handleModalVisible, - handleAddInput: this.handleAddInput, }; return ( @@ -350,9 +341,8 @@ export default class TableList extends PureComponent { ); -- GitLab