title: How to get id from last button and remove it in React using react-id-generator
body: <p>So in <code>React</code> I made a button that every time you click it it generates a new button with a unique id using <code>react-id-generator</code>.</p>
  
  <p>Now I want to get the id from the last button in the list and every time I click a remove button it should remove the last button generated.</p>
  
  <p>Here is what have I done so far and i tried to remove the last button but it removes all the buttons:</p>
  
  <pre><code>import React, { Component } from 'react';
  import Select, { components } from 'react-select';
  import styles from '../styles/loginsignup.css'
  import axios from 'axios'
  import nextId from "react-id-generator";
  export default class AccomodationInfo extends Component {
  
      constructor() {
          super();
          this.state = {
              accomcate: null,
              addroom: [''],
              isLoading: true,
          }
        }
    handleClick = event =&gt; {
          const htmlId = nextId("Room")
          event.preventDefault()
          this.setState({ addroom: [...this.state.addroom, htmlId] })
          }
  
      handleRemove = event =&gt; {
          event.preventDefault()
          this.setState({ addroom: [...""] })
      }
  
  
  
      render() {
          const{accomcate,  isLoading}  = this.state
          return(
              &lt;div&gt;
                  &lt;button onClick={this.handleClick}&gt;Add&lt;/button&gt;
                  &lt;button onClick={this.handleRemove}&gt;Remove&lt;/button&gt;
                  &lt;div&gt;
                  {this.state.addroom.map((addroom) =&gt; (
                  &lt;div&gt;
                    &lt;button id={addroom}&gt;{addroom}&lt;/button&gt;
                  &lt;/div&gt;
                  ))}
                &lt;/div&gt;
              &lt;/div&gt;
  
  
  
          )
  
  
      }
  
  
  }
  }
  </code></pre>
  
  <p>Does anyone know how to do it properly?</p>