1.0.4 • Published 1 year ago

@ganeshdole/scrolltotop v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

@ganeshdole/scrolltotop

Description

In a React Single Page Application (SPA), users often expect the view to scroll to the top when they navigate to a new page. Without this functionality, users might find themselves starting at an arbitrary scroll position, which can be confusing and lead to a poor user experience. The @ganeshdole/scrolltotop package provides a simple solution to this problem by automatically scrolling the window to the top whenever a new page is loaded using React Router.

Features

  • Automatically scrolls the window to the top when a new page is loaded.
  • Compatible with React Router.

Installation

To install the package, use npm:

npm install @ganeshdole/scrolltotop

Usage

  1. Import the ScrollToTop component from @ganeshdole/scrolltotop.
  2. Wrap the ScrollToTop component around the content of your application.
  3. Ensure React Router is set up in your project if you're using it.

Example:

import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./index.css";
import { BrowserRouter } from "react-router-dom";
import ScrollToTop from "@ganeshdole/scrolltotop";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <BrowserRouter>
    <ScrollToTop>
      <App />
    </ScrollToTop>
  </BrowserRouter>
);

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago