Skip to content

Instantly share code, notes, and snippets.

@rowlandekemezie
Last active July 4, 2017 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rowlandekemezie/5eed073802ae8e7382832084a1b6db31 to your computer and use it in GitHub Desktop.
Save rowlandekemezie/5eed073802ae8e7382832084a1b6db31 to your computer and use it in GitHub Desktop.
Passing up data from Child Component to Parent Component
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'))
import React from 'react';
const ChildA = () =>
<div>
<input type="text" />
</div>
export default ChildA;
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