I was using <Link> from @material-ui/core/Link and passing data like below:-
<Link
to={{
pathname: PATH,
search: window.location.search,
state: {
isData: true,
},
}}
>
Now, I'm switching to single-spa like below:-
import * as singleSpa from 'single-spa';
<Link
href={`${PATH}${window.location.search}`}
onClick={(e) => {
e.preventDefault();
singleSpa.navigateToUrl(
`${PATH}${window.location.search}`,
);
}}>
But in above case I am unable to pass state: {isData: true}
Here's the module for navigationToUrl:-
export function navigateToUrl(
obj:
| string
| {
currentTarget: {
href: string;
};
preventDefault: any;
},
opts?: Object
): void;
I tried the following to replicate the structure but isData isn't getting passed:-
<Link
href={`${PATH}${window.location.search}`}
onClick={(e) => {
singleSpa.navigateToUrl(
{
currentTarget: {
href: `${PATH}${window.location.search}`,
},
preventDefault: e.preventDefault(),
},
{
isData: true,
},
);
}}
>
Also, preventDefault comes to be undefined if I do above. Can someone help?