diff --git a/src/PageManager.js b/src/PageManager.js index 0f09a19..6d12d9f 100644 --- a/src/PageManager.js +++ b/src/PageManager.js @@ -43,43 +43,42 @@ export class PageManager extends Component { const pages = routes.filter(r => !r.props.noNavbar).map(r => ({ name: r.props.name, path: r.props.path })) const navbars = children.filter(child => child.type === NavigationBar) + const renderPages = (pages) => pages.map((page, i) => { + const { exact, path, ...props } = page.props + return ( + React.cloneElement(page, { ...props })} /> + ) + }) + return ( - = 0 ? "right" : "left")}> - -
- - { - animatedPages.map(page => { - const { exact, path, ...props } = page.props - return ( - React.cloneElement(page, { ...props })} /> - ) - }) - } - -
-
+
+ = 0 ? "right" : "left")}> + +
+ + { + renderPages(animatedPages) + } + +
+
+
{ - notAnimatedPages.map(page => { - const { exact, path, ...props } = page.props - return ( - React.cloneElement(page, { ...props })} /> - ) - }) + renderPages(notAnimatedPages) }
- { navbars.map((navbar) => { - return React.cloneElement(navbar, { pages }) + { navbars.map((navbar, k) => { + return React.cloneElement(navbar, { pages, key: k }) }) } - +
); } }