12

What is the difference between React.FunctionComponent and React.SFC. I'm new To typescript, and actually I don't know when to use one over the other. for example when using react hooks should I use only React.FunctionComponent, because I use some sort of state inside my component.

2 Answers 2

17

React.SFC (which stands for stateless function component) is an alias for React.FunctionComponent.

It was deprecated because functional components aren't stateless since React 16.8.

Sign up to request clarification or add additional context in comments.

Comments

10

They are the same, just one a newer terminology. Have a look at the definitions, they are both aliases for the same definition:

type SFC<P = {}> = FunctionComponent<P>;
type FC<P = {}> = FunctionComponent<P>;

1 Comment

yes that's correct, I looked to the code source and they mentioned that React.SFC is deprecated because of The new React Hooks: /** * @deprecated as of recent React versions, function components can no * longer be considered 'stateless'. Please use `FunctionComponent` instead. * * @see [React Hooks](https://reactjs.org/docs/hooks-intro.html) */ type SFC<P = {}> = FunctionComponent<P>;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.