better way
This commit is contained in:
parent
6f77a07cda
commit
d380f259b1
|
|
@ -1,18 +1,13 @@
|
|||
import { redirect } from "@tanstack/react-router";
|
||||
import { useParams } from "@tanstack/react-router";
|
||||
import { requireChains } from "@/entities/chain/lib";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
|
||||
import { useChainState } from "@/entities/chain/model";
|
||||
import { Typography } from "@mui/material";
|
||||
import { ChainButtons } from "@/widgets/chain-buttons";
|
||||
|
||||
function ChainPage() {
|
||||
const navigate = useNavigate({ from: "/$namespace/$chainId" });
|
||||
const { chainId } = useParams({ from: "/$namespace/$chainId" });
|
||||
const chain = useChainState((state) => state.getChain(chainId));
|
||||
if (!chain) return navigate({ to: "/$namespace" });
|
||||
const { chain } = Route.useLoaderData();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -43,5 +38,7 @@ export const Route = createFileRoute("/$namespace/$chainId")({
|
|||
|
||||
const selectedChain = chainState.getChain(params.chainId);
|
||||
if (!selectedChain) throw redirect({ to: "/$namespace", params });
|
||||
|
||||
return { chain: selectedChain };
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user