From the course: React: Using TypeScript (2019)
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Class/stateful component syntax
From the course: React: Using TypeScript (2019)
Class/stateful component syntax
- [Narrator] Now that we clearly understand what a class is and how it would be used in programming or React, let's revisit our class component and then add some code to our class. So let's go back to Visuals to do to do code and then open app.tsx and the first thing we're going to do is pass a type to our component. So the way you do this in a component is by using the arrows, so left and right arrow, and then pass the type any or this would work as well. So any would expect anything and this would expect an object type. So what I'm going to do for now, I'm going to do any. And again, as we discussed in the previous video, we are extended the component from React. So this one way to writing the syntax and we could do this this way as well. So we could remove all this and then simply do react.component and this is exactly the same syntax. So I'm going to go back to what I'm used to. Feel free to keep the other syntax if you want to and because we're using class call component, with it…
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
-
-
-
-
Introduction to TypeScript with React2m 17s
-
(Locked)
Basic types4m 22s
-
(Locked)
Other complex types4m 53s
-
(Locked)
Functional/stateless component intro2m 23s
-
(Locked)
Functional/stateless component syntax3m 37s
-
(Locked)
Class/stateful component intro1m 59s
-
(Locked)
Class/stateful component syntax3m 42s
-
-
-
-