fix TSC failure
This commit is contained in:
parent
313322880e
commit
1c0f633553
@ -1,14 +1,14 @@
|
|||||||
import React from "react";
|
import React, { ReactElement } from "react";
|
||||||
import { ReactNode } from "react";
|
import { ReactNode } from "react";
|
||||||
import { useLocation, useSearchParams } from "react-router-dom";
|
import { useLocation, useSearchParams } from "react-router-dom";
|
||||||
|
|
||||||
export interface IQueryRouterProps {
|
export interface IQueryRouterProps {
|
||||||
mapping: Record<string, ReactNode>;
|
mapping: Record<string, ReactElement>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const QueryRouter = ({ mapping }: IQueryRouterProps) => {
|
export const QueryRouter = ({ mapping }: IQueryRouterProps): ReactElement => {
|
||||||
const [params] = useSearchParams();
|
const [params] = useSearchParams();
|
||||||
let element = null;
|
let element: ReactElement | null = null;
|
||||||
|
|
||||||
for (const key of params.keys()) {
|
for (const key of params.keys()) {
|
||||||
if (mapping[key]) {
|
if (mapping[key]) {
|
||||||
@ -16,6 +16,7 @@ export const QueryRouter = ({ mapping }: IQueryRouterProps) => {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (element === null) {
|
if (element === null) {
|
||||||
throw new Error("missing mapping");
|
throw new Error("missing mapping");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user