Join Eve Porcello for an in-depth discussion in this video Handling state with ES6 and React.js, part of Up and Running with ECMAScript 6.
Handling State and react is also a little different in ES6.…We'll use the same restaurant component,…and we'll add on some State changes here.…The first thing I want to do is…I want to use my constructor method…to set the state for the restroom.…I'll add the constructor method here on line 8.…Now, inside my constructor method…I'm going to use super, and I'm not going to make any…changes to those properties.…And then I'll use this.state equals an object.…
Now this object is going to use status as the key,…and not open as the status.…So this will be the default for our restaurant.…It'll be set to not open,…and then it'll be up to us to make changes to that.…So we'll do this by adding by a custom…openRestaurant method,…and this openRestaurant method will trigger in a second,…so openRestaurant will use this.setState,…and we will pass in status,…and we will pass in what we want to change this to,…so we wanna change it to open.…
Awesome.…So now we need to trigger that change,…so what I will do to do this…is add a button on line 22.…
- What is ECMAScript?
- Transpiling ECMAScript with Babel and Babel-node
- Using the let and const keywords
- Creating strings with template strings
- Enhancing object literals
- Working with ES6 classes and class inheritance
Skill Level Beginner
Learn React.js: The Basics (2015)with Eve Porcello1h 32m Beginner
Up and Running with AngularJS 1with Ray Villalobos1h 20m Intermediate
Building a Polling App with Socket IO and React.jswith Alex Banks3h 56m Intermediate
1. What Is ECMAScript 6 (ES6)?
2. Transpiling ES6
3. ES6 Syntax
4. ES6 Functions & Objects
5. ES6 Classes
- 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.