title: Simplest way to generate unique Id onto a value grabbed from a form (React)
body: <p>I'm trying to grab the value from the input, assign to it a unique id, then pass the name and the id to the addFolder() function. Then the object will be pushed onto the end of the state's folders array. My main issue is trying to create a unique id </p>
  
  <pre><code>    state = {
          name: '',
          id: ''
      }
  
      static contextType = Context;
  
      handleChange = (e) =&gt; {
          this.setState({name: e.target.value, id: ?? })  &lt;-----------
      }
  
      handleSubmit = (e) =&gt; {
          e.preventDefault();
          this.context.addFolder(this.state.name, this.state.id)
      }
  
      render() {
          return (
              &lt;div&gt;
              &lt;form 
              className='AddFolderForm'
              onSubmit={this.handleSubmit}
              &gt;
                  &lt;h2&gt;Add Folder&lt;/h2&gt;
                  &lt;label &gt;Name: &lt;/label&gt;
                  &lt;input 
                  type="text"
                  id=??            &lt;------------------
                  placeholder="Folder Name"
                  value={this.state.name}
                  onChange={this.handleChange}
                  /&gt;
                  &lt;button
                      type="submit"
                  &gt;Submit
  
                  &lt;/button&gt;
              &lt;/form&gt;
              &lt;/div&gt;
          )
      }
  }
  
  
  export default AddFolder
  </code></pre>
  
  <pre><code>class App extends Component {
      state = {
          notes: [],
          folders: [],
      };
  
  .... other code...
  
  addFolder = (name, id) =&gt; {
          this.setState(prevState =&gt; ({
              folders: [...prevState.folders, {
                  "name": `${name}`,
                  "id": `${id}`,
              }]
            }))
      }
  </code></pre>