O
O
Olga Mironova2019-07-04 12:28:23
JavaScript
Olga Mironova, 2019-07-04 12:28:23

How to correctly pass props to route which is located above?

Can you please tell me how to pass props to the component above?
The tree is an
App component, 2 more components are rendered in it

const App = () => {
  return (
    <div>
      <Switch>
        <Route exact path='/' render={() => <Main />} />
        <Route path='/list' render={() => <List  />} />
      </Switch>
    </div>
  );
}

the fact is that another component is rendered in the Main component <Music />, so this Music component receives props from Main and renders another component <Track />that is wrapped in
<Link to='/list'>
  <Track ...разные пропсы и отрисовка/>
<Link />

that is, it makes sense, when I click on the track, I need to open the List component !!!, but it doesn’t get props in any way, because I need to somehow transfer them to the component to the very top (((, I tried everything, but it doesn’t work and confused (((
well pliiiiiz tell me please ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2019-07-04
@olgamiro1990

Options:
1. Rise of the state.
2. Using a state management library like redux.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question