react hoc pass props 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: high level components react
import React, { useState } from 'react';
class WelcomeName extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>
}
}
function HighHookWelcome() {
const [name ,setName] = useState("Default Name Here");
return(
<WelcomeName
name={name}
/>
);
}