jcoreio / crater

Meteor/Webpack/React SSR app skeleton that runs your app code outside of Meteor Isobuild
ISC License
82 stars 10 forks source link

redux router routing question #83

Closed Isarstyle closed 7 years ago

Isarstyle commented 7 years ago

First I wanted to thank you for this great package, its exactly what meteor needs ..

Regarding my Issue I have a react router configuration like this and want to use the kind of difference between the app containers in the redux router. Its working if i replace the Router, but then the HMR is gone.

  <Route path="/" component={App}>
    <IndexRoute component={LoginPage} />
      <Route path="login" component={LoginPage} />
      </Route>
      <Route path="/secure" component={AuthenticatedApp}>
        {/* Authentication-protected routes go here */}
          <IndexRoute component={ContactsPage} />
          <Route path="configuration">
            <IndexRoute component={UserConf} />
            <Route path="usersettings" component={UserConf} />
            <Route path="contactssettings" component={ContactsConf} />
            <Route path="*" component={NotFoundPage} />
          </Route>
          <Route path="contacts" component={ContactsPage} />
          <Route path="*" component={NotFoundPage} />
        </Route>
    <Route path="*" component={NotFoundPage} />

I tried to put it in the store objects like this:

export default (store: Store): Object => ({
  path: '/secure',
  component: AuthenticatedApp,
  indexRoute: {
    component: ContactsPage,
  },
})

but then its not using the first main app container anymore, instead shows only the child component that should be rendered in the container.

How can i define the children for specific routes in the store object?

Thank you for your help.

Isarstyle commented 7 years ago

ok got it working.

jedwards1211 commented 7 years ago

@Isarstyle ah, you don't have to use this way of defining routes if you don't want too, it should be easy to pass your existing routes in. Let me know if you want advice on how to do that.

The main reason for having (store: Store) => Route functions is in case you want to do anything dynamic with your routing, like picking a different route based upon the type of data in the store that's related to the URL. Which is kind of an advanced case.

By the way, if you put multiline code inside triple backticks instead of single backticks it will show up how you want: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#code-and-syntax-highlighting