acdlite / redux-router

Redux bindings for React Router – keep your router state inside your Redux store
MIT License
2.3k stars 216 forks source link

Failed to do dynamic loading with redux-router #284

Open joeyzhao0113 opened 7 years ago

joeyzhao0113 commented 7 years ago

Version

2.1.2

Steps to reproduce

Create a router like below:

const rootRouter = {
    childRoutes:[{
      path:'/root',
      component:MainEntry,
      childRoutes: [
        require('../containers/main_entry')
      ]
    }]
  }

 return <Router history={hashHistory}>
    <ReduxRouter>
    {rootRouter}
   </ReduxRouter>
</Router>

but when loading the page, I got below error:

Objects are not valid as a React child (found: object with keys {childRoutes}). If you meant to render a collection of children, use an array instead or wrap the object using createFragment(object) from the React add-ons.

Expected Behavior

Actual Behavior

joeyzhao0113 commented 7 years ago

I tried to use below code to put route as the value for prop in <ReduxRouter> but it doesn't work. None of the router is recognised by react. I will get a blank page with this error [react-router] Location "/" did not match any routes

<Router history={hashHistory}>
    <ReduxRouter prop={
      <Route key="root" name="root" path="/root" component={MainEntry}>
        <IndexRedirect to='/'/>
        <Route path="/" component={MainComponent} onEnter={auth}/>
      </Route>
    }>
    </ReduxRouter>
  </Router>