
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
gatsby-react-router-scroll
Advanced tools
React Router scroll management forked from https://github.com/ytase/react-router-scroll for Gatsby
The gatsby-react-router-scroll package is designed to manage scroll behavior in Gatsby applications. It provides a way to control how the page scrolls when navigating between routes, ensuring a smooth user experience.
Scroll Restoration
This feature allows you to wrap your Router component with ScrollContext to enable scroll restoration. This means that when users navigate back to a previous page, the scroll position will be restored to where they left off.
import { Router } from '@reach/router';
import { ScrollContext } from 'gatsby-react-router-scroll';
const App = () => (
<ScrollContext>
<Router>
<Home path="/" />
<About path="/about" />
</Router>
</ScrollContext>
);
Custom Scroll Behavior
This feature allows you to define custom scroll behavior by passing a function to the scrollBehavior prop of ScrollContext. This function can be used to customize how the scroll position is handled when navigating between routes.
import { Router } from '@reach/router';
import { ScrollContext } from 'gatsby-react-router-scroll';
const customScrollBehavior = ({ routerProps: { location }, getSavedScrollPosition }) => {
const savedPosition = getSavedScrollPosition(location);
window.scrollTo(...(savedPosition || [0, 0]));
};
const App = () => (
<ScrollContext scrollBehavior={customScrollBehavior}>
<Router>
<Home path="/" />
<About path="/about" />
</Router>
</ScrollContext>
);
The react-router-scroll package provides similar functionality for managing scroll behavior in applications using React Router. It allows you to control scroll position when navigating between routes, but it is not specifically tailored for Gatsby applications.
The react-scroll package offers a different approach by providing tools to animate scrolling to different parts of the page. While it doesn't manage scroll restoration between routes, it is useful for creating smooth scrolling effects within a single page.
The react-router-dom package includes basic scroll management features, such as the ability to scroll to the top of the page on route change. However, it lacks the advanced scroll restoration and custom scroll behavior features provided by gatsby-react-router-scroll.
React Router scroll management forked from https://github.com/ytase/react-router-scroll for Gatsby which itself was forked to upgrade to RR v4 from Jimmy Jia's original scroll management library for React Router 2/3.
This has been modified now to be compatible with @reach/router
.
FAQs
React Router scroll management forked from https://github.com/ytase/react-router-scroll for Gatsby
The npm package gatsby-react-router-scroll receives a total of 0 weekly downloads. As such, gatsby-react-router-scroll popularity was classified as not popular.
We found that gatsby-react-router-scroll demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.