Learn about arrays vs. objects to store the data, mapping an array into an object, and using a constant time lookup on contest click.
- [Instructor] Let's now look up…the contest when we click on it.…Right now, the route changes, but the content doesn't.…So we're going to start changing the content here.…In particular, when I click on a contest,…after I change the route, I want to look up the contest.…I want to be able to put things on the state…that are related to that contest that I just clicked.…However, the contest structure is an array.…So right now, api/contest is giving me an array.…And if I want to look up an item using the ID of that item,…I have to scan the array; that's not very efficient.…
What we can do before doing anything related…to contest lookup, is to change the structure…from an array into an object.…Once I have it as an object, my lookup…will be a constant time operation.…So this is what I'm going to do first.…I'm going to go to the api module…and in here, when I return the data as an array,…let's convert it into an object.…There are many ways to do so, the easiest way…is just to reduce array into an object.…Reduce give me a function in the first argument,…
- Configuring webpack and Babel
- Working with native Node modules
- Creating an Express server
- Working with React components and JSX
- Loading and working with test mock data
- Fetching data from a remote API
- Working with data in MongoDB
- Isomorphic rendering on the server
- Front-end routing and back-end routing
Skill Level Advanced
Building a Website with Node.js and Express.jswith Ray Villalobos3h 16m Intermediate
MEAN Stack and MongoDB: Development Techniqueswith Alexander Zanfir1h 48m Intermediate
1. Getting Started
2. Node as a Web Server
3. React Basics
4. Working with Data
5. Rendering on the Server
Fix the checksum problem6m 11s
6. Routing on Client and Server
7. Working with MongoDB
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.