Multiple Component Mapping - Walkthrough
Let’s take another look at our conditional render:
Here we’re only rendering one image, but what if state
is an array and we need multiple components?
Here we’re saying if results
array (which is a state searchResults
in <App />
and it's passed to <SearchResults />
as a prop) has a length, then take that prop and map
over it. Take each element in within our results
(if you check getImages()
you'll see we've taken only url
of images) and place it inside of the img
where the src
attribute is.
You should now have a working app! Well done!