Understanding why super() is deprecated in a React class component

后端 未结 4 777
闹比i
闹比i 2020-12-05 22:33

I\'m new to React and I\'m learning about the React component lifecycle with the latest version of React. My "super" call of the partial code below is flagged with

4条回答
  •  失恋的感觉
    2020-12-05 23:16

    super(props); isn't deprecated yet. The deprecation message actually caused from a bug in React's type definition file and is already fixed as of @types/react 16.9.51. Just upgrade the package and you're good to go:

    npm install @types/react
    

提交回复
热议问题