- Overview
- Transcript
2.6 Challenge: Build a Component
1.Introduction2 lessons, 04:39
1.1Introduction01:31
1.2Application Demo03:08
2.Get Started With Redux6 lessons, 41:43
2.1Set Up the Project09:34
2.2Reducers and Actions10:10
2.3Combining Reducers08:42
2.4Challenge: Add a Case to a Reducer04:44
2.5Challenge: Split a Reducer05:19
2.6Challenge: Build a Component03:14
3.Create React Components8 lessons, 50:18
3.1Build a Pure Component04:53
3.2Start the Sidebar04:31
3.3Write Action Creators08:37
3.4Use Action Creators06:42
3.5Challenge: Temperature Converter05:50
3.6Challenge: Todo List09:21
3.7Challenge: Action Creators07:26
3.8Challenge: Refs Research02:58
4.Application Structure9 lessons, 56:09
4.1Refactor Our Application for Growth08:43
4.2Using the `react-redux` Package13:12
4.3Add a Router07:24
4.4Create Nested Routes07:44
4.5Add `localStorage` Support03:38
4.6Challenge: Presentational and Container Components07:26
4.7Challenge: Basic Routing02:53
4.8Challenge: Route Not Found02:51
4.9Challenge: Route Parameters02:18
5.Implement the App9 lessons, 1:31:34
5.1Create the Toolbar06:16
5.2Create the New Card Modal15:16
5.3Display a Deck of Cards05:27
5.4Create the Edit Card Modal10:20
5.5Filter Cards06:24
5.6Create a Study Interface19:29
5.7Add Asynchronous Actions13:08
5.8Challenge: General Conversion Component07:11
5.9Challenge: Users List Component08:03
6.Conclusion1 lesson, 01:32
6.1Conclusion01:32
2.6 Challenge: Build a Component
It's time for challenge number three. In this challenge you need to build a component. So notice here's a react component for displaying a Twitter avatar, as you can see it just takes props.handle and it prints out this little URL in an image tag. Very simple. And what we need to do is write a profile component that uses a Twitter avatar component to show the image and the name, and you can see the ReactDOM.render call for some hints. All right. Now remember, you can find a link to this pen under the video. I'm gonna go ahead and fork this, so that we can build our own component here. And once again, I'll rename it with my solution. Okay, now we're actually getting into using react, within these challenges. So this gets a little more exciting, go ahead and pause this video right now if you want to do this challenge yourself because now I'm going to show you the answer. In our React dom call here we have a profile component that we're calling, and we give it a name and we give it a handle. So this should be pretty straightforward. Let's go ahead and create a profile. And I'm gonna do this as a stateless component. Just using a JavaScript function. If you want, you can actually use react.create class, or the class syntax itself. Do whatever you like. But I like using stateless functions as much as possible. As we can see this is gonna take one parameter of course which is our prox subject but it's gonna have name and handle properties. So let's go ahead and destructure that. And then let's return a div here. And, let's see, inside this div, let's return an h1 with the name for this specific account, or person I guess. And underneath this, we will have a TwitterAvatar. And, let's see, it requires a handle property. So we will pass it a handle, which will be equal to the handle we have. There we go. It should be that simple. So I'm gonna go ahead and save this and it looks like we are doing something wrong because nothing is appearing over here in our output. So let me pop open the console, hane is not find. I've misspelt something similar. Yes, this is not name. Let's go ahead and say name. And now if we close the console you can see that we get reactJS and we get the Twitter avatar. Let's go ahead and change this so i can change the name here to be Andrew Burgess and you can see that it updates there. And of course that's nothing to do with react that's just code, and re-running the code. But anyway, we can change the handle here to Andrew 8088 and, what? That's not me. Okay, that's strange. I guess Twitter's having a problem. Let's change this to, I don't know, Facebook. Now let's see, what do we get? There, we get the Facebook avatar. And if we change this to Tuts+, there we go we get the Envato Tuts. Okay so let's go with that one. So as you can see we can change this to different names and Twitter avatars and we can see this in action. So good job, you have built a very basic component. But it's a good place to start in seeing how you can create components and use their properties, and also how you can pass those properties on to other components, to do some of the work for you. Good job.