"this" is the keyword, which holds reference to something, in this case, this is used within a class naming Foo, so when we use the keyword "this" inside the class it refers to class itself.
By meaning it reference to Foo, means now you can access the other properties and function belonging to class with help of this keyword. Class is like a blueprint, does not exist on its own, we create objects/instances of classes to access them. Once the object/instance is made, and we want to access the properties of class among themselves we use this keyword.
In react object creation is done by below syntax
<Foo />
That when the component is being called. Now in constructor by using the code
this.state = {
bar: "baz",
}
we are making sure that we can access bar key across this component from any other function as well. something like below
render(){
console.log(this.state.bar);
return (<div>{this.state.bar}</div>)
}
Hope this helps.