OSDN Git Service

add the unique ID for the redux form field.
authorZhiting Lin <zlin035@uottawa.ca>
Wed, 29 Aug 2018 06:35:52 +0000 (14:35 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Wed, 29 Aug 2018 06:35:52 +0000 (14:35 +0800)
src/features/transactions/components/New/AdvancedTransactionForm.jsx

index 01a319b..6474368 100644 (file)
@@ -20,7 +20,8 @@ class AdvancedTxForm extends React.Component {
     super(props)
     this.state = {
       showDropdown: false,
-      showAdvanced: false
+      showAdvanced: false,
+      counter: 0
     }
 
     this.submitWithValidation = this.submitWithValidation.bind(this)
@@ -40,10 +41,15 @@ class AdvancedTxForm extends React.Component {
   }
 
   addActionItem(type) {
+    const counter = this.state.counter
     this.props.fields.actions.addField({
       type: type,
+      ID: counter
     })
     this.closeDropdown()
+    this.setState({
+      counter: counter+1
+    })
   }
 
   disableSubmit(actions) {
@@ -97,7 +103,7 @@ class AdvancedTxForm extends React.Component {
         <FormSection title='Actions'>
           {actions.map((action, index) =>
             <ActionItem
-              key={index}
+              key={action.ID.value}
               index={index}
               fieldProps={action}
               accounts={this.props.accounts}
@@ -254,6 +260,7 @@ export default BaseNew.connect(
     form: 'AdvancedTransactionForm',
     fields: [
       'signTransaction',
+      'actions[].ID',
       'actions[].accountId',
       'actions[].accountAlias',
       'actions[].assetId',