Declare a local variable in constructor for capturing context.
I faced the same issue while using class className extends React.Component
instead of createClass()
. Create a variable in constructor to fix this.
constructor(props) {
super(props);
self = this;
}
Use self.props
instead of this.props
everywhere!