ReasonJun

React : Passing values to components through props 본문

Frontend/React

React : Passing values to components through props

ReasonJun 2023. 6. 11. 15:26
728x90

Props is short for properties. When we need to deliver a value to a component, we use props.

  1. When using ‘Hello’ component in App component, it delivers the value of name.

2. Props delivered to components can be inquired through parameters. Props is delivered in the form of an object, and if you want to look up the ‘name’ value, you can look up ‘props.name’.

Multiple props, unstructured assignments

Set default to defaultProps

If you want to set the default value to use when you do not specify props for a component, you can set the value defaultProps for the component.

 

 

 

 

728x90
Comments