title: How to use react-select with api
body: <p>I use react-select as a dropdown for autosearch
  import the library and render component:</p>
  <pre><code>&lt;Select
                className='search-line'
                placeholder='Search...'
                options={dataList}
                onChange={opt =&gt; console.log(opt)}
                   /&gt;
  </code></pre>
  <p>The problem is that options is data that comes from API as an array of objects :</p>
  <pre><code>const data = [
    { id: 1,
      name: 'Bmw'
    },
    { id: 2,
      name: 'Ferrary'
        }
  ]
  </code></pre>
  <p>but to render options react-select requires  objs with such key-val as</p>
  <pre><code>const options = [
      { value: name, label: name}
  ]
  </code></pre>
  <p>How to loop through my array and change that value and label obj key-val ?</p>
  <p>This works but it splits all the names I have in array of objects I fetch from API:</p>
  <pre><code>   const name  = data.map(i =&gt; {
       return i.name
     })
  
    const dataList = [
      { label: name, label: name}
    ]
  </code></pre>
  <p>Data - is a prop with data (array of objects fetched from API)</p>