cra-template-07
Advanced tools
Comparing version 2.0.4 to 2.0.5
{ | ||
"name": "cra-template-07", | ||
"version": "2.0.4", | ||
"version": "2.0.5", | ||
"proxy": "https://localhost:44332/", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -11,2 +11,3 @@ import React, { useContext } from "react"; | ||
import Page from "components/Layout/Page"; | ||
import Home from "components/Layout/Home"; | ||
import DevMode from "components/Dev/DevMode"; | ||
@@ -33,9 +34,17 @@ | ||
<Routes> | ||
{routes?.map((page) => ( | ||
<Route | ||
path={page.url} | ||
key={page.url + "route"} | ||
element={<Page page={page} />} | ||
/> | ||
))} | ||
{routes?.map((page) => | ||
page.isRoot ? ( | ||
<Route | ||
path={page.url} | ||
key={page.url + "route"} | ||
element={<Home page={page} />} | ||
/> | ||
) : ( | ||
<Route | ||
path={page.url} | ||
key={page.url + "route"} | ||
element={<Page page={page} />} | ||
/> | ||
) | ||
)} | ||
</Routes> | ||
@@ -42,0 +51,0 @@ |
@@ -38,6 +38,7 @@ import React, { createContext, useState, useEffect } from "react"; | ||
if (data?.children) { | ||
setRoutes((routes) => | ||
Array.isArray(routes) | ||
? [...routes, ...data.children] | ||
: [data, ...data.children] | ||
setRoutes( | ||
(routes) => | ||
Array.isArray(routes) // If routes is array | ||
? [...routes, ...data.children] // Merge both routes and children into new array | ||
: [{ ...data, isRoot: true }, ...data.children] // If routes is not array, initiate array with root and children | ||
); | ||
@@ -44,0 +45,0 @@ data.children.forEach((singleNode) => { |
42542
27
948