-
Notifications
You must be signed in to change notification settings - Fork 72
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
"window" is not available during server side rendering #80
Comments
Hi @yudyananda can you check this out https://www.gatsbyjs.org/docs/debugging-html-builds/#fixing-third-party-modules and this. The package uses window to check when you resize the browser but |
Hi @femioladeji many thanks for quick answer try with creating util
the result is not as i expected, the slider goes inside another div, in this case another approach is using loadable-component, works fine, but it caused delay on initial page loading (other element below will overlap slider position before it fully load) |
@yudyananda it's weird that it's going into the |
the result is slider goes inside next element below => sorry for bothering you, i'll get back to you with example repo |
@yudyananda it's fine. Let me know when you have an example repo. I'm always here to help |
I had the same issue on my gatsby Website and I solved this using loadable-components. However it is not as good as expected since, as @yudyananda mentioned, it causes delay on page load. I am not sure what the best solution is. |
@mluce194 yes you're correct. The window event is used to handle browser resizing. I'm considering using resize-observer-polyfill but I don't know if it will completely solve the SSR issue. I'll continue to make research and hopefully, I'll come up with a solution that works perfectly. |
Hi @femioladeji, sorry for the late reply. You can check the repo here not sure whats going on here but
I really hope you can change on how react-slideshow work to make it more suitable (ssr ready) for other framework like gatsby |
@yudyananda thanks for reproducing the issue. I've taken a look at it and I've fixed the issue with this PR #81 . I've released a new version (v2.0.1). You don't need any workaround to use it anymore. I've fixed it all in the package so you can remove the import React from 'react'
import { useStaticQuery, graphql } from 'gatsby'
import Img from 'gatsby-image'
import { Fade } from 'react-slideshow-image'
import 'react-slideshow-image/dist/styles.css'
const fadeProperties = {
duration: 5000,
transitionDuration: 1000,
infinite: true,
indicators: false,
onChange: (oldIndex, newIndex) => {
console.log(`fade transition from ${oldIndex} to ${newIndex}`);
}
}
const Slider = () => {
const data = useStaticQuery(graphql `
query {
allFile(
sort: { fields: name, order: DESC }
filter: { relativeDirectory: { eq: "slider" } }
) {
edges {
node {
id
name
childImageSharp {
fluid(maxWidth: 1200, maxHeight: 585, quality: 100) {
...GatsbyImageSharpFluid_withWebp
...GatsbyImageSharpFluidLimitPresentationSize
}
}
}
}
}
}
`)
return (
<div className="slide-container front-slider pointer-events-none">
<Fade {...fadeProperties}>
{data.allFile.edges.map(image => (
<div className="each-fade">
<div className="image-container select-none">
<Img className="rounded" alt="first bro" key={image.node.name} backgroundColor fluid={image.node.childImageSharp.fluid} />
</div>
</div>
))}
</Fade>
</div>
)
}
export default Slider As regards the positioning, I think it has to do with the div wrapping the Let me know if this works for you |
Hi there, i'm using latest version react-slideshow in my gatsby js powerd website. everything is working fine on develop mode but it throws me an error on build process.
"window" is not available during server side rendering
this is my component
I wonder how to make it works on build?
The text was updated successfully, but these errors were encountered: