4.0.0-beta.5
import React from 'react'
import { Route } from 'react-router-dom'
const WithSubRoutes = (route) => {
return (
<Route {...route} render={props => (
<route.component {...props} routes={route.routes} />
)} />
)
}
export default WithSubRoutes
export default [
{
pattern: '/',
component: Home,
exactly: true
}
]
const BaseRoute = () => {
return (
<div>
{routes.map((route, i) => (
<WithSubRoutes key={i} {...route} />
))}
</div>
)
}
Home with any generic component.Warning: You should not use <Route component> and <Route render> in the same route; <Route render> will be ignored from this warningcomponent: Home to render: Home and updating the MatchWithSubRoutes to use <route.render ... /> does not return the warning. component: ... in my route config, the console emits a warning. Happy to open a PR with updates to the docs if that's all it is! AWESOME work :)
Is that code somewhere in the docs?
The issue is you're spreading the entire route config object into the <Route>'s props in WithSubRoutes, which includes the component prop. Easiest fix is to just rename that property to something like routeComponent and render <route.routeComponent ....
Most helpful comment
Is that code somewhere in the docs?
The issue is you're spreading the entire route config object into the
<Route>'s props inWithSubRoutes, which includes thecomponentprop. Easiest fix is to just rename that property to something likerouteComponentand render<route.routeComponent ....