Skip to content

Instantly share code, notes, and snippets.

@jasminegmp
Created February 22, 2020 18:36
Show Gist options
  • Save jasminegmp/a70023bb25ab1a0e5cc2599bcd57b263 to your computer and use it in GitHub Desktop.
Save jasminegmp/a70023bb25ab1a0e5cc2599bcd57b263 to your computer and use it in GitHub Desktop.
import React from 'react';
class Parent extends React.Component{
constructor(props){
super(props);
this.state = {
data: 'Data from parent'
}
}
render(){
const {data} = this.state;
return(
<div>
<Child dataParentToChild = {data}/>
</div>
)
}
}
class Child extends React.Component{
constructor(props){
super(props);
this.state = {
data: this.props.dataParentToChild
}
}
render(){
const {data} = this.state;
return(
<div>
{data}
</div>
)
}
}
export default Parent;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment