H
H
Herberito Galustyan2019-08-03 19:40:58
typescript
Herberito Galustyan, 2019-08-03 19:40:58

When should I use React.FC?

I have a component like this Should I use React.FC ?
const Herberito = ( x ) => <div>{x}</div>;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-08-04
@Herberto

Example:

interface Props {
  someProp: string;
}

const Herberito: React.FC<Props> = ({ someProp }) => <div>{someProp}</div>;

If you don't pass in external properties or children, then React.FC's type can be omitted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question