Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
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
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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.