I'm new to React and I'd try to tinker a little bit with dataflow when using and some kind of output.
The idea is to type something in an input bar and have it shown below the bar as the user is typing. I wish to do this without stuff like Flux or Redux please. Just a simple little thing to get me familiar with dataflow.
I have a component Input
class Input extends Component {
render() {
return (
<input value={this.props.inputValue} onChange={this.props.onChange} />
);
}
}
And a component Output
class Output extends Component {
render() {
return (
<p>
{this.props.dataSource}
</p>
);
}
}
Encapsulated in a parent component which is just App
class App extends Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
this.onChange = this.onChange.bind(this);
}
onChange(event) {
this.setState({
value: event.target.value,
});
}
render() {
return (
<div>
<Input inputValue={this.state.value} onChange={this.onChange} />
<Output dataSource={this.state.value} />
</div>
);
}
}
But the Output component doesn't seem to read the value
from the parent component.
Also I question whether this is even the right way. Storing data in the parent component instead of the individual components themselves.