Search code examples
javascriptreactjscomponents

What Does a Line Though "super(props)" Mean? See image


I'm creating a React app, and as of right now, everything working fine. However I've noticed is VSCode that there is a line though the "super(props)" line. Just wondering what this means? I've never seen it before, and do not understand

enter image description here


Solution

  • The strikethrough is the sign for "deprecated" - it means that VSCode thinks that the React.Component#constructor(props) method is deprecated (it isn't).

    This is probably because you're using the 1.49+ version of VSCode which ships with TypeScript 4.0+. TypeScript 4.0 understands the @deprecated JSDoc tag, but there is a bug in TypeScript's support for @deprecated when combined with overloads. Because of this, even though the @types/react definition only deprecates the second constructor which takes in a legacy context argument VSCode is seeing all the constructors as being deprecated. In this case the warning is safe to ignore.