title: How to pass one prop as a variable to another prop in React?
body: <p>May I know how to pass a prop as a variable to another prop passed to the child component? </p>
  
  <p>So in parent component I use pass two props "name" and "formProps" to a child like this:</p>
  
  <pre><code>&lt;FormField name="id" formProps={formProps} /&gt;
  &lt;FormField name="amount" formProps={formProps} /&gt;
  </code></pre>
  
  <p>In className of the Child Component, I want to make the {props.name} as a variable to the {props.formprops.errors}, but I don't know how to.</p>
  
  <p>I want it be like this:</p>
  
  <p>When "name" prop equals to "id",</p>
  
  <pre><code>props.formProps.errors.`${props.name}` 
  </code></pre>
  
  <p>is </p>
  
  <pre><code> props.formProps.errors.id
  </code></pre>
  
  <p>When "name" prop equals to "amount",</p>
  
  <pre><code>props.formProps.errors.`${props.name}`
  </code></pre>
  
  <p>is</p>
  
  <pre><code> props.formProps.errors.amount
  </code></pre>
  
  <p>But there's error. May I know how should I write it? Thank you so much!</p>
  
  <pre><code>const FormField = (props) =&gt; {
  return (
  ......
  &lt;Field
     type="text"
     name={props.name}
  
     className={props.formProps.errors.`${props.name}` &amp;&amp; props.formProps.touched.`${props.name}` ? 'is-invalid form-control' : 'form-control'}
  /&gt;
  )
  }
  </code></pre>