Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is React super(props) deprecated?

I've always used something similar to

class MyComponent extends React.Component {
    constructor(props) {
        super(props)
        
        this.state = {
            var1 : undefined,
            var2 : 'etc...',
        }
    }
}

But today I noticed while working in VS Code there is a strike-thru line on super(props), which was never there before !?

enter image description here What has changed? (the link to the docs in the popup is not very helpful)

like image 701
joedotnot Avatar asked Sep 17 '20 04:09

joedotnot


2 Answers

My guess is that your editor is showing you the description for the super(props, context) signature which is deprecated. That link it's pointing to is all about how the old context API is going away, and that particular call signature is part of what is leaving.

However, I haven't heard of a plain super(props) going away, you should be safe to continue using that.

like image 128
Scotty Jamison Avatar answered Oct 11 '22 14:10

Scotty Jamison


It looks like a bug. Please see - here for explanation and there is a link to a source.

like image 12
bladerunner2020 Avatar answered Oct 11 '22 15:10

bladerunner2020