Joseph MicheliniPython Development Techdegree Graduate 18,692 Points
What are the syntax rules for adding component properties in React?
At some point in the video, we initialize a property
prevPlayerId in App.js to
4. The syntax caught me a little off-guard, because we use a
= to initialize it, and I'm used to using
: to initialize properties on objects and classes. Is this similar to calling the App component and adding the property in-line, except in this case we're adding it in the class definition?
Thanks in advance!
Clinton HaysFront End Web Development Techdegree Graduate 16,420 Points
I think I'm understanding your question correctly and believe I have the answer. We can initialize properties of the component by declaring them and initializing them this way. This is similar to the way we initialize the
state of the App. The only difference is with
state we are creating an object while
prevPlayerId is just initializing a number.
I submit this answer with the caveat that I am only mostly sure that I've got it right. Haha. This is just the way that seemed to make sense to me.