pass props to components code example
Example 1: pass props in react
const expression = 'Happy';
<Greeting statement='Hello' expression={expression}/>
class Greeting extends Component {
render() {
return <h1>{this.props.statement} I am feeling {this.props.expression} today!</h1>;
}
}
Example 2: class component params in react
<input
type= "text"
value={ this.state.value || "" }
placeholder="Enter Name"
/>
Example 3: pass props
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}