I just started using React native on iOS to see how it feels like and I have a silly question.. I see everyone talking about "Props", whenever I read an article or a tutorial, the author uses this term a lot and it's the same in the code. For instance, in class declarations I often see constructors like :
class MyClass extends Component {
constructor(props) {
super(props);
this.state = { message: '' };
}
}
I can't find a clear explanation of what a prop is, could anyone enlighten me about that ?
Props are arguments passed into React components. Props are passed to components via HTML attributes. props stands for properties.
A prop, formally known as (theatrical) property, is an object used on stage or screen by actors during a performance or screen production. In practical terms, a prop is considered to be anything movable or portable on a stage or a set, distinct from the actors, scenery, costumes, and electrical equipment.
While both hold information that influences the output of render, they are different in one important way: props get passed to the component (similar to function parameters) whereas state is managed within the component (similar to variables declared within a function).
Props stand for "Properties." They are read-only components. It is an object which stores the value of attributes of a tag and work similar to the HTML attributes. It gives a way to pass data from one component to other components.
props are the values that you pass down to your React component. So whenever you have a component you'll see something like this:
<MyComponent value1={value1} isTrue={true} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With