Created
February 22, 2020 18:36
-
-
Save jasminegmp/a70023bb25ab1a0e5cc2599bcd57b263 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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