React alloıs us to send data to a component in the same syntax as HTML, using attributes or properties on a component. This is akin to passing the src attribute to an image tag. We can think about the property of the < img /> tag as a prop we're setting on a component called img . We can access these properties inside a component as this.props . Let's see props in action. Recall, we defined the < Header /> component as: When we use the < Header /> component, we placed it in our component as like so: We can pass in our title as a prop as an attribute on the < Header / > by updating the usage of the component setting the attribute called title to some string, like so: Inside of our component, we can access this title prop from the this.props property in the Header class. Instead of setting the title statically as Timeline in the template, we can replace it with the property passed in. Now our < Header /> compone
ආසිරි හේවගේ විසින් රචනා කරන ලද
Comments