Guest User

Untitled

a guest
Jul 17th, 2018
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. {
  2. pages: [
  3. {
  4. id: 1,
  5. name: "Home",
  6. name_slug: "home",
  7. content: [] // contains complete content
  8. }, {
  9. ...
  10. }
  11. ]
  12. }
  13.  
  14. buildRoutes() {
  15. const { pages, isFetching, ...rest } = this.props;
  16.  
  17. if(!isFetching && pages.length !== 0) {
  18. return pages.map((page) => {
  19. const path = page.isFrontPage ? '/' : `/${page.name_slug}`;
  20.  
  21. return (
  22. <Route
  23. exact
  24. key={page.id}
  25. path={path}
  26. component={() => <Page content={page.content}/>}
  27. />
  28. );
  29. });
  30. }
  31. }
Add Comment
Please, Sign In to add comment