How can use props in react?
Props in react:
We can use
props in simply three ways one is direct with {props.propertyName} , second as
object and third is as destructuring method. As you can understand with below
code:
export default (props) => {
return (
<div className="section-title">
<h2>{props.heading2}</h2>
<p>{props.paragraph}</p>
</div>
)
}
export default ({heading2,paragraph}) => {
return (
<div className="section-title">
<h2>{heading2}</h2>
<p>{paragraph}</p>
</div>
)
}
export default (props) => {
// destructring
const {heading2,paragraph} = props;
return (
<div className="section-title">
<h2>{heading2}</h2>
<p>{paragraph}</p>
</div>
)
}
No comments:
Note: Only a member of this blog may post a comment.