otterscan/src/Address.tsx

29 lines
840 B
TypeScript
Raw Normal View History

2022-08-22 22:17:04 +00:00
import React from "react";
import { useSearchParams } from "react-router-dom";
import AddressMainPage from "./AddressMainPage";
2021-07-01 18:21:40 +00:00
const AddressTransactionByNonce = React.lazy(
2022-08-05 21:54:30 +00:00
() => import("./AddressTransactionByNonce")
);
2022-08-22 22:17:04 +00:00
/**
* This is the default handler for /address/* URL path.
*
* It can redirect to different child components depending on search
* query params, so it is not possible to use default path routing
* mechanisms to declarative-model them.
*/
const Address: React.FC = () => {
// Search address by nonce === transaction @ nonce
2022-08-22 22:17:04 +00:00
const [searchParams] = useSearchParams();
const rawNonce = searchParams.get("nonce");
if (rawNonce !== null) {
2022-08-22 22:17:04 +00:00
return <AddressTransactionByNonce rawNonce={rawNonce} />;
}
2022-08-22 22:17:04 +00:00
// Standard address main page with tabs
return <AddressMainPage />;
2021-07-01 18:21:40 +00:00
};
export default Address;