Using ES6+ syntax in React/React-Native, the variable foo, when defined outside of the constructor is somehow transformed into an instance variable when called with this.. Is my assertion true? Why does it even work, when not instantiated in the constructor? Here a corresponding React Native code snippet:
class myComponent extends Component {
constructor() {
super();
}
foo = "bar";
render() {
return ( <View>{ this.foo }</View> );
}
}
This discussion about ES7 property initializers shows how the state variable is prominently used in this way in React/React Native.
So far related Stack Overflow discussions I read through here and here could not answer this question for me..