0
<Router>
    <Route path="/" component={ Layout }>
        <IndexRoute component={ Home } />

        <Route path="packages" component={ Package }/>
        <Route path="packageDetail/:packageId"   component={ PackageDetail } />

        <Route path="*" component={ NotFound } />
    </Route>
</Router>

how to pass props from packages to packageDetail which dont have parent child relationship?

Bhanu prathap
  • 94
  • 2
  • 10

2 Answers2

1

use Redux or any other Flux system to have a global application state filling react component with common props.

Damien Leroux
  • 11,177
  • 7
  • 43
  • 57
0

Should it have anything to do with the React Router at all? It all depends on what Flux/Store implementation you are using (Alt.js, Redux or whatever). If you are within packages and do something then it should be registered in some Store (for example PackageStore if you have Alt.js where you are having plenty of stores - if you are using Redux and have one global state it is even easier), where both PackageDetails and Package should use. So even if you will change view it should still have access.

Though in your case I would still change the routing to more

<Route path="package" component={ Package }>
   <Route path="package-id" omponent={ PackageDetails } />
</Route>
Shiroo
  • 666
  • 4
  • 11