/* PASSING THE PROPS to the 'Greeting' component */
const expression = 'Happy';
// statement and expression are the props (ie. arguments) we are passing to Greeting component
/* USING THE PROPS in the child component */
class Greeting extends Component {
render() {
return
{this.props.statement} I am feeling {this.props.expression} today!
;
}
}
Example 3: pass function with parameter as prop
class SomeComponent extends Component{
constructor(props){
super(props);
//does whatever stuff
this.myFunction = this.myFunction.bind(this);
}
//(only applicable to raw and normal forms)
myFunction(param){
console.log('do something: ', param);
}
render(){
return (
)
}
}
class ChildComponent1{
render(){
return (
)
}
}
class ChildComponent2{
render(){
return ()
}
}