-
Notifications
You must be signed in to change notification settings - Fork 29
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
onStepEnter isn't being called in gatsby #40
Comments
Hi there! first of all thanks for the lib. I really like the simplicity of the api. I ran into an issue that is related to the fix you are mentioning for this issue. Since you are now "calculate(ing) offset heights and intersection margins" only on document.load and not on component mount Could you elaborate why this change was introduced? To me it feels counter intuitive to trigger the calculation only on docoument.load. I believe you actually should calculate anything on |
Ran into same issue @maerzhase is describing, tried loading via dynamic import in next.js with ssr:false option, on document.load it works, and then on route change stops working |
Ah, thanks so much for the explanations @maerzhase @olegrjumin. Apologies, I've never really worked with non SPAs before. Would a solution be to move the calculations back to |
no luck for me still. this works `
}` |
From the react documentation doing the whole calculation in
The DOM is supposed to be available. Could you share an example were you ran into the problem that you could not retrieve DOM elements on mount? Maybe this was in a early version of react? Same goes for the original issue here. @jjrchrds could you share an runnable environment that shows your issue? From what I undestand going from |
@maerzhase thanks for your fix, It unblocked me! |
@maerzhase I may have spoken too soon. My website runs with Looks like the lib is trying to reference window at build time: |
Jeah this will always be the case you have to opt out server side rendering for this lib, since there is no window on the server. Usually you do this with dynamic imports. e.g. https://nextjs.org/docs/advanced-features/dynamic-import |
@maerzhase thanks for the suggestion. I tried out an implementation using loadable-components:
But now I'm getting a new error when trying to execute the built bundle:
I guess getting this working on Gatsby is going to be quite a bit more work than I originally anticipated. EDIT: Turns out I just needed to move my code around taking into account how Gatsby works (get underlying data at build time and pass the data to a loadable component at runtime). Doh! |
yeah figured that this has nothing to do with the library per-se because i am using it in production builds + ssr. the lib could address ssr though (or at least mention it in the readme) |
Simple reproduction of the issue, by copy pasting the code in the readme https://codesandbox.io/s/fervent-brown-v0l20?file=/src/App.js |
clearly still the same issue. Initialising the lib on |
Apologies for the delay. I'm willing to use componentDidMount. There is still this issue however. What if we called the "domDidLoad" function both in CDM and document.load? |
Could you provide an example for this case? Usually DOM related properties should be available on |
I will create an example repo some time today/tomorrow. For now, I will push a version with redundant code. If I can't reproduce it tomorrow, I will remove the redundancy. |
This is released in v2.2.11 @jjrchrds @maerzhase @maxkrieger @goleary @olegrjumin |
The codesandbox from @maxkrieger still doesn't work with v2.2.11
@jsonkao you totally ignored what i wrote in #47. If you use The error you will see is: |
Ah my bad, I hadn't noticed your changes to |
Released in v2.2.12 @maerzhase |
I'm trying to get the example working in Gatsby. The component renders, but onStepEnter is never actually called:
The text was updated successfully, but these errors were encountered: