refactor: tighten types and reuse instrument UI
This commit is contained in:
@@ -65,6 +65,8 @@ describe("AppRoutes", () => {
|
||||
path: { pathname: "/login", state: { returnTo: "//example.com" } },
|
||||
title: "Вход",
|
||||
},
|
||||
{ endpoint: "login", path: { pathname: "/login", state: { returnTo: 42 } }, title: "Вход" },
|
||||
{ endpoint: "login", path: { pathname: "/login", state: 42 }, title: "Вход" },
|
||||
])("authenticates via $endpoint and reaches the protected landing from $path", async ({ endpoint, path, title }) => {
|
||||
let credentials: unknown;
|
||||
server.use(
|
||||
|
||||
@@ -24,15 +24,15 @@ class Boundary extends Component<BoundaryProps, State> {
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
state: State = { hasError: false };
|
||||
override state: State = { hasError: false };
|
||||
|
||||
componentDidUpdate(previousProps: BoundaryProps) {
|
||||
override componentDidUpdate(previousProps: BoundaryProps) {
|
||||
if (previousProps.routeKey !== this.props.routeKey && this.state.hasError) {
|
||||
this.setState({ hasError: false });
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
override render() {
|
||||
return this.state.hasError
|
||||
? <RouteErrorFallback authenticated={this.props.authenticated} />
|
||||
: (
|
||||
|
||||
@@ -30,8 +30,11 @@ const Public: FC<PropsWithChildren> = (props) => {
|
||||
|
||||
if (!ready) return <RouteSkeleton variant="shell" />;
|
||||
|
||||
const requested = (location.state as null
|
||||
| { returnTo?: string })?.returnTo;
|
||||
const state: unknown = location.state;
|
||||
|
||||
const requested = state && typeof state === "object" && "returnTo" in state
|
||||
? state.returnTo
|
||||
: undefined;
|
||||
|
||||
const returnTo
|
||||
= typeof requested === "string"
|
||||
|
||||
Reference in New Issue
Block a user