Answer the question
In order to leave comments, you need to log in
How to pass data to components using a router?
I understand with react, I have several components on the main page, I pass data to them like this. <myComponent data={this.state.data} />
I decided to add a router to the page
, it turned out something like this
<Router>
<Fragment>
<Menu />
<Route exact path='/component' component={myComponent} />
<Route path='/another-component' component={mySecondComponent} />
</Fragment>
</Router>
Answer the question
In order to leave comments, you need to log in
how now to pass data to these components from it?
<Route exact path='/component' render={() => <myComponent prop={value}/>} />
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question