Skip to content

Commit

Permalink
intially fetch url version instead of default version (#281)
Browse files Browse the repository at this point in the history
* intially fetch url version instead of default version

* fix linting

* add build output

* add error checking and default version
  • Loading branch information
bprize15 authored Dec 17, 2024
1 parent d3df2a6 commit d7bf3ed
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 29 deletions.
13 changes: 9 additions & 4 deletions web/src/main/javascript/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "./app.scss";
import OncoTree, { OncoTreeNode } from "@oncokb/oncotree";
import { useCallback, useEffect, useState } from "react";
import "react-toastify/dist/ReactToastify.css";
import { Bounce, ToastContainer } from "react-toastify";
import { Bounce, toast, ToastContainer } from "react-toastify";
import News from "./pages/News/News";
import {
DEFAULT_VERSION,
Expand All @@ -18,7 +18,7 @@ import About from "./pages/About/About";

function App() {
const location = useLocation();
const [, setSearchParams] = useSearchParams();
const [searchParams, setSearchParams] = useSearchParams();

const [oncoTreeData, setOncoTreeData] = useState<OncoTreeNode>();
const [oncoTree, setOncoTree] = useState<OncoTree>();
Expand All @@ -33,8 +33,13 @@ function App() {
}

useEffect(() => {
fetchData(DEFAULT_VERSION);
}, []);
const version = searchParams.get('version');
try {
version ? fetchData(version) : fetchData(DEFAULT_VERSION);
} catch {
toast.error("Error fetching OncoTree data");
}
}, [searchParams]);

useEffect(() => {
if (location.pathname !== PageRoutes.HOME) {
Expand Down
Loading

0 comments on commit d7bf3ed

Please sign in to comment.