Skip to content

Commit

Permalink
feat(Redirect): customRoutes now accept <Redirect /> (#2771)
Browse files Browse the repository at this point in the history
* feat(Redirect): customRoutes now accept <Redirect />

Fix [#2767](#2767)

* fix(customRoutes): Using cloneElement for customRoutes

* fix(customRoutes): Remove <Redirect /> unused imports. Fixed RoutesWithLayout not rendering customRoutes as an array

* fix(customRoutes): Remove ...route.props when cloning routes

* chore(clean): removed .idea and package-lock.json

* chore(ignore): removed .idea and package-lock.json

* fix(CoreAdminRouter): do not force exact to true on resourcesRoutes
  • Loading branch information
kopax authored and fzaninotto committed Jan 28, 2019
1 parent b60d233 commit cc3d5ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
20 changes: 7 additions & 13 deletions packages/ra-core/src/CoreAdminRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,13 @@ export class CoreAdminRouter extends Component {
<Switch>
{customRoutes
.filter(route => route.props.noLayout)
.map((route, index) => (
<Route
key={index}
exact={route.props.exact}
path={route.props.path}
render={props =>
this.renderCustomRoutesWithoutLayout(
route,
props
)
}
/>
))}
.map((route) => cloneElement(route, {
render: props =>
this.renderCustomRoutesWithoutLayout(
route,
props
)
}))}
<Route
path="/"
render={() =>
Expand Down
12 changes: 1 addition & 11 deletions packages/ra-core/src/RoutesWithLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ const RoutesWithLayout = ({

return (
<Switch>
{customRoutes &&
customRoutes.map((route, index) => (
<Route
key={index}
exact={route.props.exact}
path={route.props.path}
component={route.props.component}
render={route.props.render}
children={route.props.children} // eslint-disable-line react/no-children-prop
/>
))}
{customRoutes && customRoutes.map((route) => cloneElement(route))}
{Children.map(children, child => (
<Route
key={child.props.name}
Expand Down

0 comments on commit cc3d5ca

Please sign in to comment.