Skip to content

Element hidden on load when using with gatsby #55

New issue

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

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

Already on GitHub? # to your account

Closed
carstenblt opened this issue Sep 4, 2019 · 2 comments
Closed

Element hidden on load when using with gatsby #55

carstenblt opened this issue Sep 4, 2019 · 2 comments

Comments

@carstenblt
Copy link

When using gatsby, a Plx element remains hidden (display: 'hidden') and only shows, when you start scrolling. This happens about 50% of the time and seems to be a race condition.

I believe this is an issue with gatsby, because it doesn't support using_window_ inside render(). Using _animateWhenNotInViewport _ works as a workaround. I can't give you much insight though as I'm still new to the ecosystem.

@Stanko
Copy link
Owner

Stanko commented Sep 5, 2019

Hello @carstenblt,
I don't think it is a race condition.

Initially I added visibility: hidden on purpose, to hide element until client code is loaded, then it is removed when component is mounted:
https://github.com/Stanko/react-plx/blob/master/source/Plx.js#L553-L556

Can you provide me with a code example please?

Cheers!

@Stanko
Copy link
Owner

Stanko commented Jan 15, 2020

Unfortunately, this is how server rendered React and Gatsby work.
Check this Gatsby issue I opened - gatsbyjs/gatsby#12413

Closing as it is not problem with the library itself.

@Stanko Stanko closed this as completed Jan 15, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants