Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highway crashes on import (SSR) #64

Closed
fsdiogo opened this issue Jan 17, 2020 · 4 comments
Closed

Highway crashes on import (SSR) #64

fsdiogo opened this issue Jan 17, 2020 · 4 comments

Comments

@fsdiogo
Copy link

fsdiogo commented Jan 17, 2020

I'm using Next.js which has server-side rendering and Highway crashes on import due to the window not being defined in the server.

With a quick look in the source code, I've found that changing this line

const PARSER = new window.DOMParser();

to something along the lines of

const PARSER = typeof window !== 'undefined' ? new window.DOMParser() : undefined;

stops the crash (at least with the features of Highway I'm using at the moment).

I still have to import the non-built version to make it work even after rebuilding the project with the mentioned change (I'm npm linking the project):

import Highway from '@dogstudio/highway/src/highway';

Do you have something planned to make Highway work with SSR?

@Anthodpnt
Copy link
Contributor

Hello @fsdiogo,

There is no support of React applications because there is no need of Highway for this type of project. The routing is managed by Next.js and there are already plenty of good tools for animations in React:

react-transition-group
react-spring

Best regards,
Anthodpnt

@fsdiogo
Copy link
Author

fsdiogo commented Jan 20, 2020

Hi @Anthodpnt,

I've used react-transition-group before but I'd say its focus is on transitioning between components, whereas Highway's main objective is to transition between pages, so I gave it a shot 👍

Thanks anyway!

@ThaoD5
Copy link
Contributor

ThaoD5 commented Jan 20, 2020

Hello @fsdiogo,

For page transitions under Next, I am currently working with next-page-transition module

It seems to do the job pretty well, just keep in mind that having both views overlapping at the same time is not possible with this module.

Have a great day

@fsdiogo
Copy link
Author

fsdiogo commented Jan 20, 2020

Hi @ThaoD5,

I gave that a go too and it worked well yes, but it had some drawbacks like no scroll restoration and no out-of-the-box support for css modules due to not spreading some props to react-transition-group (which it's using as a dependency).

If I have the time maybe I'll try to use react-transition-group directly.

Thanks, you too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants