DEV Community

Discussion on: Explain State and Props Like I'm Five

Collapse
 
_phzn profile image
Kevin Lewis

I'd really welcome feedback if this isn't right or the best way of explaining them, but here's a shot:

State holds data and variables which are specific to a component. They work like object/class properties.

Props are options which you can pass into a component when you create them, often as an attribute, such as <Person eyes="brown"> - the prop is eyes, value is brown. You have to handle that in your component.

Collapse
 
david_j_eddy profile image
David J Eddy

What is the difference between 'state' and an OOP object?

Collapse
 
zspencer profile image
Zee • Edited

Hey David,

In my understanding, React and Vue state is an extension of an object, with some tools for noticing changes and informing the React or Vue framework about those changes so the framework/virtual machine can do something with those changes.

So state in react is a kind of object, but the inverse is not true (object is not a kind of state)

I hope this helps!

Zee

Thread Thread
 
david_j_eddy profile image
David J Eddy

Very helpful, TY. Coming from a backend programming perspective and just recently learning VueJS state confused me a bit. Your explanation helps.

Collapse
 
lauragift21 profile image
Gift Egwuenu

Thanks for breaking this down