This.props.talk vs. this.talk


#1



Code works but looking for a brief explanation as to when each of the following would be appropriate (it is clear to me that the ladder is for accessing a method defined by the bottom level 'talk', but when would the first be used?):


this.props.talk

vs.

this.talk


#2

Since we're dealing with classes, then what have are instances or class attributes.

{this.talk}

is the prop and it is instanced within the class, and in the same context as the talk function. It's actually this method that is being passed to the Button component, which is another class with its own render function. It's context is this but that this does not point to the same context as the one in Talker. To refer to the inputs in the same context as the component, we still need this.

{this.props.talk}

It's tricky to get one's head around (at least for me it is) so I expect there is much missing in this reply. Must do some more reading...


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.