Create stateless React components using TypeScript

Share this video with your friends

Send Tweet

You can create a stateless React component in TypeScript as easily as creating a function.

But if you want to create high quality idiomatic React + TypeScript components we cover some improved patterns in this lesson.

Angshuman Agarwal
Angshuman Agarwal
~ 5 years ago

React.SFC is deprecated now. Use : https://github.com/basarat/react-typescript/blob/master/src/app/app.tsx

Sarmad ajaz
Sarmad ajaz
~ 4 years ago

Can we create a type like

type someProps = { compiler: string, framework: string }

const App: React.FC<someProps> = (props) => { return ( <div> <div>{props.compiler}</div> <div>{props.framework}</div> </div> ); }

Basarat Ali Syed
Basarat Ali Syed(instructor)
~ 4 years ago

Yes Sarmad:

type SomeProps = { compiler: string, framework: string }

const App: React.FC<SomeProps> = (props) => { 
  return (
    <div>
      <div>{props.compiler}</div>
      <div>{props.framework}</div>
    </div>
  );
}