mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 17:25:59 +02:00
fix: window is not available during gatsby build
Check if window is available, and set initial value for `state.scrollY`.
This commit is contained in:
committed by
Jean-Philippe Sirois
parent
38e1a4ba56
commit
5ba1e86672
@@ -39,7 +39,6 @@ const BoxedTitle: React.FC<IBoxedTitleProps> = (props) => {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
const debounce = (fn) => {
|
||||
let frame
|
||||
return (...params) => {
|
||||
@@ -57,12 +56,15 @@ export class HeaderBarebone extends Component<IHeaderBareboneProps, HeaderBarebo
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.tick = this.tick.bind(this)
|
||||
this.state = { scrollY: 0 }
|
||||
}
|
||||
|
||||
tick() {
|
||||
this.setState({
|
||||
scrollY: window.scrollY
|
||||
})
|
||||
if (typeof window !== 'undefined') {
|
||||
this.setState({
|
||||
scrollY: window.scrollY
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
|
||||
Reference in New Issue
Block a user