Is there a difference between using this.props vs props in React?
No diffrence.
props === this.props // true
Basically, it's same in this case, but if you consider the whole component then props
can only be available if you pass props
as function argument such as below example
componentWillMount(){
this.someFunc(this.props);
}
componentWillReciveProps(nextProps){
this.someFunc(nextProps);
}
someFunc(props) {
......
// in here props and this.props are completely different
as props is you latest props while this.props can be you previous props
}
while you can access this.props
from anywhere of you component, i hope this gives you the idea
The rules for ES2015 (ES6) classes basically come down to:
In a child class constructor, this cannot be used until super is called.
ES6 class constructors MUST call super if they are subclasses, or they must explicitly return some object to take the place of the one that was not initialized.
So as the super(props) is called in the constructor. props and this.props are same. so,
props === this.props // true