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

Fix SSR detection in Deno #1522

Merged
merged 1 commit into from
Apr 22, 2022
Merged

Fix SSR detection in Deno #1522

merged 1 commit into from
Apr 22, 2022

Conversation

heypiotr
Copy link
Contributor

@heypiotr heypiotr commented Apr 21, 2022

Deno provides a window object, which makes Framer Motion believe it's running in a browser when using Deno for SSR. They suggest checking the document instead:

denoland/deno#13367

There's a few more typeof window checks in dist, centered around window.requestAnimationFrame. I suspect these are coming from some dependency. In my testing (SSRing www.framer.com/sites in Deno), they haven't caused any trouble, despite window.requestAnimationFrame being undefined (which means if there is some code path which triggers them, it would crash).

image

@@ -21,7 +21,6 @@ let hasListeners = false

function addEventListeners() {
hasListeners = true
if (typeof window === "undefined") return
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addEventListeners is called in an effect, which makes this check redudant. But let me know if you feel it's better to leave it in.

@heypiotr heypiotr marked this pull request as ready for review April 21, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Land this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants