From the course: React for Web Designers
Unlock this course with a free trial
Join today to access over 22,400 courses taught by industry experts.
Implement props - React.js Tutorial
From the course: React for Web Designers
Implement props
- [Instructor] In this video, we're going to implement props for the first time and see how that one way data flow happens at a basic level. So we've said that we need a top level customizer component to own the data, because the image needs to know the color of the sneaker, and of course, the color selector, when we eventually have one, is going to need to know that as well. So the state we care about will eventually come from the product customizer and be passed down to these child components as props. Anything a child component needs, state, callback functions, whatever, comes in as props. So switching back to the code, here's what we're going to do. We're going to pass in things that we need to these child components, from the product customizer. To start out, we're going to keep this super simple. We're just going to pass in some hard coded props. So for the product image, what we're going to need to know is what color to display. So let's set up a color prop, we'll just pass in…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Installing React on an existing site8m 7s
-
Identifying your components and data3m 19s
-
Set up first simple component5m 31s
-
Start using JSX with the help of Babel7m 57s
-
Attaching a data source3m 20s
-
Create a new component with array data5m 56s
-
Implement props4m 28s
-
Implement state with the useState hook5m 11s
-
Add the color selector component3m 27s
-
Change options, see reactions6m 14s
-
Challenge: Activate the color selector1m 58s
-
Solution3m 4s
-
-
-
-