DEV Community

KeeyboardKeda
KeeyboardKeda

Posted on

I think I have a handle on this.state...

State and Props hold information that changes over time for the component. Everything else should remain the same. State: should be equal to an object. Example,
this.state ={mood: 'great'}; Mood is the property and great is a string value. To read a components state use the expression: this.state. name-of-property. Example,

I'm feeling {this.state.mood}

.

I was going over an example and i randomly see this.handleLoggedIn in the code. I had no idea why it was there and it was briefly mentioned in another document that i had opened. "In React, it’s conventional to use on[Event] names for props which represent events and handle[Event] for the methods which handle the events." So I figured out this.handle...Handle is used as an event handler/listener and used when creating a function in a React element. There is so much more to me figuring that out but my mentor helped me!

Until next time !

Top comments (0)