Learn about refactoring in the green state. Learn about computable properties and how we should not have them on the state.
- [Instructor] Let's do some refactoring.…First, let me extract this long line here…that fetches a current contest into its own method.…I'm going to call this method this.currentContest.…We need to invoke it, so currentContest is a method…that just returns this line, making sure things still work.…Perfect. We always refactor…in the green state when things are working…and we're not getting any errors.…So what I want you to think about now…is this pageHeader, which we start with a static value…and then, once we click on a contest,…it actually gets its own value from the contest name.…
But this pageHeader can't actually be computed.…We don't need to put it on the state.…If we have a contestId, we're going to…read the current contest name.…If we don't have a current contestId,…we just go with the default naming contest.…So I'm going to actually remove it from the state…and instead, let's create a pageHeader function.…So this is very simple.…If I have a current contestId on the state,…then the pageHeader is going to be this.currentContest,…
- 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?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
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.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.