title: React/JS How would I assign a specific mapped element to a state?
body: <p>My search component returns a mapped list of results based on the input. Depending on the list element clicked, I want to assign it to my current stock state but I am not sure how I would access that specific element.</p>
  <pre><code>const selectStock = ()=&gt;{
      setSearch(&quot;&quot;);
      setCurrentStock();
    }
  
  return (
    &lt;div className=&quot;searchContainer&quot;&gt;
      &lt;form className=&quot;searchBar&quot;&gt;
        &lt;input
          className=&quot;search&quot;
          type=&quot;text&quot;
          placeholder=&quot;Search Ticker Symbol&quot;
          onChange={handleSearch}
        /&gt;
      &lt;/form&gt;
      &lt;div className=&quot;searchResults&quot;&gt;
        &lt;ul&gt;
          {/* {stockNames.map((stockname) =&gt; {
          const { name, symbol} = stockname;
          return (
              &lt;li className=&quot;displaySearch&quot; onClick={selectStock} key={symbol}&gt;
                  &lt;p&gt;{name} ({symbol})&lt;/p&gt;
              &lt;/li&gt;
          );
        })} */}
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  );
  </code></pre>
  <p>}</p>