mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +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) => {
|
const debounce = (fn) => {
|
||||||
let frame
|
let frame
|
||||||
return (...params) => {
|
return (...params) => {
|
||||||
@@ -57,12 +56,15 @@ export class HeaderBarebone extends Component<IHeaderBareboneProps, HeaderBarebo
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.tick = this.tick.bind(this)
|
this.tick = this.tick.bind(this)
|
||||||
|
this.state = { scrollY: 0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
tick() {
|
tick() {
|
||||||
this.setState({
|
if (typeof window !== 'undefined') {
|
||||||
scrollY: window.scrollY
|
this.setState({
|
||||||
})
|
scrollY: window.scrollY
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
|
|||||||
Reference in New Issue
Block a user