New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-scroll

Package Overview
Dependencies
Maintainers
0
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll

A scroll component for React.js

1.9.3
latest
Source
npm
Version published
Weekly downloads
509K
-2.5%
Maintainers
0
Weekly downloads
 
Created

What is react-scroll?

The react-scroll package provides smooth scrolling functionality for React applications. It allows developers to create scrollable components and implement smooth scrolling animations to specific elements within a page.

What are react-scroll's main functionalities?

Smooth Scrolling to Elements

This feature allows you to create links that smoothly scroll to specific elements on the page. The 'Link' component is used to create the scrollable link, and the 'Element' component is used to define the target section.

import { Link, Element } from 'react-scroll';

function App() {
  return (
    <div>
      <Link to="section1" smooth={true} duration={500}>Go to Section 1</Link>
      <Element name="section1" className="element">
        Section 1
      </Element>
    </div>
  );
}

Scroll Events

This feature allows you to register and handle scroll events. You can log or perform actions when scrolling begins or ends. The 'animateScroll' function can be used to programmatically scroll to specific positions.

import { Events, animateScroll as scroll, scroller } from 'react-scroll';

function App() {
  useEffect(() => {
    Events.scrollEvent.register('begin', function() {
      console.log('begin', arguments);
    });

    Events.scrollEvent.register('end', function() {
      console.log('end', arguments);
    });

    return () => {
      Events.scrollEvent.remove('begin');
      Events.scrollEvent.remove('end');
    };
  }, []);

  return (
    <div>
      <button onClick={() => scroll.scrollToTop()}>Scroll to Top</button>
    </div>
  );
}

Scroll to Top

This feature provides a simple way to scroll to the top of the page programmatically. The 'scrollToTop' function from 'animateScroll' is used to achieve this.

import { animateScroll as scroll } from 'react-scroll';

function App() {
  return (
    <div>
      <button onClick={() => scroll.scrollToTop()}>Scroll to Top</button>
    </div>
  );
}

Other packages similar to react-scroll

Keywords

react

FAQs

Package last updated on 19 Feb 2025

Did you know?

Socket

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.

Install

Related posts