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 intro

Class/stateful component intro

From the course: React: Using TypeScript (2019)

Start my 1-month free trial

Class/stateful component intro

- [Instructor] If you've worked with React before, you've got some experience working with a class component. But you may be wondering why are we using a class? Or what is a class? If you're very familiar with the concept of a class, feel free to skip this video and move onto the syntax next. First, a class is a syntax that was introduced in ES6, in JavaScript, but also is used quite a bit in TypeScript. The class syntax allows you to create a type of blueprint for specific code and attach methods and other properties that can be leveraged later. For example, think of a warrior class, as we are seeing on the screen here. This warrior class could defined with properties for a warrior, such as strength, agility etc, and then in the class we could define a few functions, such as fight and explore. Now that we've defined this warrior class, we could extend it to a ninja class and then define it further, with its own properties and methods. For example, we could add a shuriken property and…

Contents