Query Params With Preact + Vite + preat-iso

83 Views Asked by At

I have just switched over to using Preact + Vite and the router that is contained in preact-iso instead of preact-router.

Previously, I was able to get the query params into a component like this:

type Props = {
    prop1?: number;
    prop2?: string;
};

const SomeComponent: FunctionComponent<Props> = ({prop1, prop2}) => {
};

Now, I have to deconstruct them from the query object like this:

type Props = {
    query: {
        prop1?: number;
        prop2?: string;
    }
};

const SomeComponent: FunctionComponent<Props> = ({query: {prop1, prop2}}) => {
};

Is this the right way to get the query params or is there a better way?

0

There are 0 best solutions below