React 16.7 - React.SFC is now deprecated

Jonas Praem picture Jonas Praem · Dec 21, 2018 · Viewed 33.6k times · Source

I use to declare stateless components like this:

const example: React.SFC<IExample> = ({propsType}) => ();

However the SFC is now deprecated, maybe this twitter post from Dan Abramov explains why.

What should we use now that SFC is deprecated?

Answer

Doğancan Arabacı picture Doğancan Arabacı · Dec 21, 2018

You should use React.FunctionComponent: Rename React's SFC to 'FunctionalComponent

This PR renames React.SFC and React.StatelessComponent to React.FunctionComponent, while introducing deprecated aliases for the old names.

So your example would become:

const example: React.FunctionComponent<IExample> = ({propsType}) => ();

or

const example: React.FC<IExample> = ({propsType}) => ();