you can render the list as shown below example with array.
Example code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import React, { useState } from 'react'; import ReactDOM from 'react-dom/client'; //App function component function App() { const items = ['apple', 'banana', 'orange']; return ( <> <h2>Example of React List</h2> <ul> {items.map((item) => <><div>{item}</div></>)} </ul> </> ) } const root = ReactDOM.createRoot(document.getElementById("root")); //creating a root React component in your application root.render(<App />) // rendering React components into a DOM node. |
Output:
