Skip to content

Instantly share code, notes, and snippets.

@anishtr4
Last active November 19, 2018 08:36
Show Gist options
  • Save anishtr4/b8ef69e73d32cfcb2e9eaf2de126a58a to your computer and use it in GitHub Desktop.
Save anishtr4/b8ef69e73d32cfcb2e9eaf2de126a58a to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
function ParentComponent(props) {
return (
<ChildComponent value={props.value} />
);
}
function ChildComponent(props) {
return (
<GrandChildComponent value={props.value} />
);
}
function GrandChildComponent(props) {
return (
<div className="Component2"> <p>{props.value}</p></div>
);
}
class ProVal extends Component {
state = {
inputdata: 0
};
updateInputValue = (evt) => {
this.setState({
inputdata: evt.target.value
});
}
render() {
return (
<div>
<ParentComponent value={this.state.inputdata} />
<input value={this.state.inputdata} onChange={this.updateInputValue} />
</div>
);
}
}
export default ProVal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment