Last active
July 4, 2017 04:29
-
-
Save rowlandekemezie/5eed073802ae8e7382832084a1b6db31 to your computer and use it in GitHub Desktop.
Passing up data from Child Component to Parent Component
This file contains hidden or 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'; | |
import { render } from 'react-dom'; | |
import ChildA from './childA.js'; | |
import ChildB from './childB.js'; | |
class App extends React.Component { | |
handleKeyUp() { | |
console.log('Event bubbling: Passing up data from Child to Parent component'); | |
} | |
render() { | |
return (<div onKeyUp={this.handleKeyUp.bind(this)}> | |
<ChildA /> | |
<ChildB /> | |
</div>) | |
} | |
} | |
render(<App />, document.getElementById('root')) |
This file contains hidden or 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'; | |
const ChildA = () => | |
<div> | |
<input type="text" /> | |
</div> | |
export default ChildA; |
This file contains hidden or 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'; | |
const ChildB = () => | |
<div> | |
<input type="text" /> | |
</div> | |
export default ChildB; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment