Answer the question
In order to leave comments, you need to log in
How to pass data from component to component using routes?
class Header extends Component {
constructor(props) {
super(props);
this.state = {
select: false
};
}
render() {
return <div>{this.state.select}</div>;
}
}
class Main extends Component {
send = () => {
// Отсюда необходимо изменить состояние в Header на this.state.select = true
}
render() {
return <button onClick={this.send}></div>;
}
}
ReactDOM.render(
<Router history={browserHistory}>
<Route path="/" component={Header}>
<Route path="main" component={Main}/>
</Route>
</Router>,
document.querySelector('.app')
);
Answer the question
In order to leave comments, you need to log in
Here is a general approach to this issue.
But it is applicable in academic projects or tiny applications.
In reality, you need to use dataflow packages. Please love and favor - Redux .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question