<script src="https://unpkg.com/react@17.0.2/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@17.0.2/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/@babel/standalone@7.14.7/babel.min.js"></script>
<script type="text/babel">
// Your original data array with objects
{ id: 1, name: "Item 1", category: "Category A" },
{ id: 2, name: "Item 2", category: "Category B" },
{ id: 3, name: "Item 3", category: "Category A" },
{ id: 4, name: "Item 4", category: "Category C" },
{ id: 5, name: "Item 5", category: "Category B" },
{ id: 6, name: "Item 6", category: "Category A" },
// Define the range you want to render (e.g., index 2 to 5)
const slicedData = data.slice(startIndex, endIndex + 1);
<div className='container'>
<h3>React map index range Example</h3>
{slicedData.map((item, index) => (
// Render your components here using the 'item' data
<p>Category: {item.category}</p>
ReactDOM.render(<App />, document.getElementById("app"));
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12),
0 2px 4px 0 rgba(0, 0, 0, 0.24);
/* Styling for the heading */
/* Styling for the list */
/* Styling for the list items */
/* Styling for odd-indexed list items (alternating background) */
.container li:nth-child(odd) {
background-color: #f9f9f9;