In the last section, we set up our Form component, but now we need to create our next component FormResults. This component will be where use to display the results from our API query.
Let's just get started by setting up our component. We need to make sure that it's displaying in our app. Go into the FormResults.js file. Since we just need this component to display our form results, we're not requiring access to state or anything, we can make this a functional component.
Now that we have our results available to use, we can start working on formatting our results to display them. We can make an unordered list of all of our results, and give it an ID of "results". It's important that this ID is the same because it's used in our parent component. Go ahead and make your return statement look like this one:
To challenge yourself, see if you can set up this map before looking at the code below. Go through it step by step! This is an example image of what it should look like when done. Scroll down to see the finished code for this component when you're done. Here we show one of Carolyn's favorite movies:
FormResults
We also need to call the component. Remember that this is a component that we can pass the results to, that will handle displaying them. Go back to the Form.js file and make your render() look like this:
Now, we just need to figure out how to format our results for display! We're going to use map again to take our results and turn them each into a list item with all the information we want. There is a way to grab movie posters for each movie with The Movie Database API, and we're going to use it to display movie posters with our movies! You can read about it in the docs . We're going to take our results and map them into list items with the following things: 1. unique keys 2. an img tag with the movie poster URL 3. the name of the movie 4. the release date
Next, we're going to talk about a fun way to style react components, called styled-components!!!