router-kit 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,6 +6,7 @@ import RouterContext from "./RouterContext";
|
|
|
6
6
|
const RouterProvider = ({ routes }) => {
|
|
7
7
|
const [path, setPath] = useState(window.location.pathname);
|
|
8
8
|
let fullPathWithParams = "";
|
|
9
|
+
let page404 = _jsx(Page404, {});
|
|
9
10
|
const pathValidation = (routeFullPath, currentPath) => {
|
|
10
11
|
const routePaths = routeFullPath.split("|");
|
|
11
12
|
for (const routePath of routePaths) {
|
|
@@ -33,7 +34,7 @@ const RouterProvider = ({ routes }) => {
|
|
|
33
34
|
for (const route of routesList) {
|
|
34
35
|
const is404 = route.path === "404" || route.path === "/404";
|
|
35
36
|
if (is404 && route.component) {
|
|
36
|
-
|
|
37
|
+
page404 = route.component;
|
|
37
38
|
}
|
|
38
39
|
const fullPath = join(parentPath, `/${route.path}`);
|
|
39
40
|
if (pathValidation(fullPath, currentPath)) {
|
|
@@ -50,7 +51,7 @@ const RouterProvider = ({ routes }) => {
|
|
|
50
51
|
};
|
|
51
52
|
fullPathWithParams = "";
|
|
52
53
|
const matchedComponent = getComponent(routes, path);
|
|
53
|
-
const component = matchedComponent !== null && matchedComponent !== void 0 ? matchedComponent :
|
|
54
|
+
const component = matchedComponent !== null && matchedComponent !== void 0 ? matchedComponent : page404;
|
|
54
55
|
const navigate = (to, options) => {
|
|
55
56
|
if (options && options.replace) {
|
|
56
57
|
window.history.replaceState({}, "", to);
|
package/package.json
CHANGED