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.

Functional/stateless component intro

Functional/stateless component intro

From the course: React: Using TypeScript (2019)

Start my 1-month free trial

Functional/stateless component intro

- [Teacher] If you have some experience with React, you know exactly what functional components are, but in this video, we'll start exploring how they work in relation to TypeScript, and then do some code that we'll finish in the next video. A functional component, at its core, is a Javascript function. Therefore, its syntax won't change much from a function where we return something. In this case, we return HTML to be rendered into our obligation. So how does TypeScript change this? Not that much. The only difference is that we define what are the types we pass into the function's arguments, and also the return type. In other words, we'll dig deeper into how to do functions in TypeScript while coding a component. Let's get started. So the first thing I'm going to do is create a brand new component, and I'm going to go into the Source folder, and then click on New File. And I'm going to call this one message.tsx so we keep the extension for TypeScript. And let's go ahead and create a…

Contents