Join Eve Porcello for an in-depth discussion in this video Updating components, part of Learning React.js.
- [Instructor] Now let's focus on updating our component.…The first thing I'm going to do here is I'm going to,…instead of using get default props, use get initial state.…When our application renders, when our app loads,…we're going to return an initial state…of background color purple,…height and width of 200.…Then, I want to assign this to our div…that's being rendered in this component,…so let's go ahead and simplify it,…and we're just going to render the one div,…so the surrounding div, and the section can go.…
I'm going to change our style property to this dot state.…The next thing I'm going to do is add an update method.…The update method is going to handle any changes…that occurred to my div.…The update is going to change the state…using this dot set state,…and here, we will return an object…with a key of background color,…and a background color of red.…Every time the update function is called,…it's going to set the background color state to red.…
I can attach this to our div using an on click property.…
- What is React.js?
- Introducing JSX
- Creating a React component
- Handling events
- Using state
- Working with PropTypes
- Adding child elements
- Mounting and updating components
- Creating a React.js app
Skill Level Beginner
Building a Web Interface with React.jswith Ray Villalobos1h 21m Intermediate
1. What Is React.js?
2. Getting Started
3. React Components
4. Props and State
5. Enhancing Components
6. Creating an App
Using create-react-app4m 38s
Next steps1m 4s
- 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.