Im trying to get my head around 'Components' in React.
I have a few questions so I thoughts I'd SO community is the best place to ask them.
1 - When we do this:
var foo = React.createClass ({
...
});
Console.log tells me that this is a constructor. So when we do <foo />
, we are creating an instance (object) of foo, correct?
2 - Im particularly getting confused by this
, here is the example:
var bar = React.createClass ({
render = function () {
if (this.props.xyz) {
...
}
}
});
Now <bar />
is a child component of foo. When bar
instance is instantiated, this
should refer to 'bar', shouldn't it? Why is it still referencing foo
?
3 - Suppose I created multiple instaces of <foo />
. How do we store reference to each particular object?