From the course: Creating a Serverless Application Using React in AWS

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Load JSON as data in your React component

Load JSON as data in your React component

- [Instruct] Let's go ahead and use our data. So we have what is going to look to our react application, a lot like data. It really doesn't care if it's from a JSON file, which this is, or if it's from a database which we're going to get to later. What we do have, is we have a variable called menu links data, that has JSON information in it. And it is organized in terms of links, each item has a class, in HRF and a text. So we can use that now within our UL, we're going to insert a couple of curly braces, which allows us to now write JavaScript. And we want to take our object, our menu links data and we're going to use the map function. So with map, what we can do is we can map from the information in menu links data, to a desired output format. And so for each item, we're just going to call it link because each item does represent a link. It has the class of the link, the atria for the link and the text of the link.…

Contents