Skip to content

Commit

Permalink
Using a Query Fragment as initialPath
Browse files Browse the repository at this point in the history
  • Loading branch information
sergesoroka committed Sep 3, 2024
1 parent 1eadb22 commit 4e99db7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions components/h5web/h5web.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import "@h5web/app/dist/styles.css";

import { App, HsdsProvider } from "@h5web/app";
import { useLocation, useSearchParams } from "react-router-dom";
import { useLocation, useSearchParams, useParams } from "react-router-dom";
import { useState } from "react";

// eslint-disable-next-line react/prop-types
export default function H5web({ domain }) {
Expand All @@ -12,7 +13,14 @@ export default function H5web({ domain }) {
const queryParams = new URLSearchParams(location.search);
const h5webParams = queryParams.get("h5web");

const initialPathParams = searchParams.get("initialPath")
const initialPathParams = searchParams.get("initialPath");

const [hash, useHash] = useState(decodeURIComponent(window.location.hash.substring(1)))


const initialPath = initialPathParams ? initialPathParams :
hash ? hash : '/'



return (
Expand All @@ -24,7 +32,7 @@ export default function H5web({ domain }) {
password="system-public-user"
filepath={`${domain ? domain : h5webParams}`}
>
<App initialPath={initialPathParams ? initialPathParams : '/'} />
<App initialPath={initialPath} />
</HsdsProvider>
</div>
</div>
Expand Down

0 comments on commit 4e99db7

Please sign in to comment.