Chrome Extension

Get index in map React

function items() {
    const nums = [1, 2, 3, 4];
    return <div>
        {nums.map( (num, index) => 
            <div key={index.toString()}>{num}</div>
        )}
    </div>;
}
We are a bunch of lazy programmers so we developed this chrome extension
search code from your favorite search engine
Install Now

In the map function, you can find the index as its second parameter. 

Was this helpful?
0 Comments
Open Code Manager We are hiring