Skip to content Skip to sidebar Skip to footer

React Native : Access Component State Inside A Static Function

I have a component defined like this export class A extends Component{ constructor(props){ this.state = { scene:0 } } static changeScene(scene){ thi

Solution 1:

Reason is, if you use static function then a static method won't be able to access this inside that function. You should avoid using static function. Static methods have no access to the values, properties, and methods defined on an instance of the class using this.

Check this article: http://odetocode.com/blogs/scott/archive/2015/02/02/static-members-in-es6.aspx

Post a Comment for "React Native : Access Component State Inside A Static Function"