Skip to content
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

fix: Several Fixes for Scroll Handling and Restoration #24306

Merged
merged 15 commits into from
Jun 19, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/gatsby-react-router-scroll/src/scroll-container.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: In Gatsby v3, this file should be removed.
// We are deprecating this in V2 in favor of useScrollRestoration
import * as React from "react"
import ReactDOM from "react-dom"
import PropTypes from "prop-types"
Expand All @@ -23,9 +25,25 @@ interface IPropsWithContextAndLocation extends IProps {
location: HLocation
}

let hasNotWarnedDeprecation = true

class ScrollContainerImplementation extends React.Component<
IPropsWithContextAndLocation
> {
constructor(props) {
super(props)

if (hasNotWarnedDeprecation) {
blainekasten marked this conversation as resolved.
Show resolved Hide resolved
hasNotWarnedDeprecation = false
console.warn(
`Deprecation Warning: Gatsby <ScrollContainer> is deprecated in Gatsby v2 and will be removed in Gatsby v3.`
)
console.warn(
`Deprecation Warning: Update to the React hook alternative useScrollRestoration`
)
}
}

componentDidMount(): void {
// eslint-disable-next-line react/no-find-dom-node
const node = ReactDOM.findDOMNode(this) as Element
Expand Down