Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

661
Views
How to pass data through single-spa navigateToUrl()?

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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!