Below is an example of a basic React component that renders a list of items from an array:
179 chars12 lines
The component takes a prop items
, which is an array of objects with an id
and name
property. It uses the map
method to iterate through each item in the array and return a list item with the name
as its text content. The key
prop is set to the id
of each item for performance optimization. Finally, the list items are wrapped in an unordered list (<ul>
) element.
gistlibby LogSnag