Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

I can't get the HIGHWAY.redirect() to work #103

Closed maubut closed 3 years ago

maubut commented 3 years ago

Hello,

I need to make a document.location.href for a specific case. Reading the documentation, I understand that I should use the HIGHWAY.redirect(href).

However, on my side, the highway.redirect(href) just doesn't work. A ''highway_1.default.redirect is not a function'' error occurs.

Here is the code snippet of my default-renderer.ts:

import Highway from '@dogstudio/highway';
import DefaultRenderer from '../custom-renderer';

class FrontpageRenderer extends DefaultRenderer  {

  ...

  onEnter() {
   const cards  = Array.from(document.querySelectorAll('.artist-box'));

      for (const card of cards) {
        const link = card.querySelector('.view-artist')?.getAttribute('href');

        (card as HTMLElement).onclick = (e) => {
          Highway.redirect(link);
          e.preventDefault();
        }
      }
  }

  ...

}

It must have something with my understanding but do you have any ideas?

maubut commented 3 years ago

How can I remove this issue, I'm feeling a little awkward right now!

I'm migrating my code from Barba to highway and I was just currently calling the redirect() method the wrong way...