Search code examples
reactjsionic-frameworkhashbreadcrumbs

How do I configure my Ionic breadcrumbs to only change the hash of the URL when clicked?


I'm using Ionic 7 and React 18. I have constructed these Ionic breadcrumbs ...

    <IonBreadcrumbs>
      <IonBreadcrumb {...(isSenderCompleted() ? { href: '#sender' } : {})}>Sender</IonBreadcrumb>
    ...
    </IonBreadcrumbs>

with the intention being that if someone clicks one of the breadcrumbs, only the hash portion of the URL changes. However, the above doesn't accomplish this -- it seems to interpret the hash as a full URL.


Solution

  • Turns out to properly have the hash switched out in the URL, I shouldn't have used "href", but rather "routerLink", e.g.

          <IonBreadcrumb>
            {isSenderCompleted() ? <IonRouterLink routerLink={`#sender`}>Sender</IonRouterLink> : <span>Sender</span>}
          </IonBreadcrumb>