我像这样声明无状态组件:
const example: React.SFC<IExample> = ({propsType}) => ();
然而证监会现在已被弃用,也许this twitter post from Dan Abramov解释原因。
现在 SFC 已被弃用,我们应该使用什么?
最佳答案
你应该使用React.FunctionComponent
:Rename React's SFC to 'FunctionalComponent
This PR renames
React.SFC
andReact.StatelessComponent
toReact.FunctionComponent
, while introducing deprecated aliases for the old names.
所以你的例子会变成:
const example: React.FunctionComponent<IExample> = ({propsType}) => ();
或
const example: React.FC<IExample> = ({propsType}) => ();
关于reactjs - React 16.7 - React.SFC 现已弃用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53885993/