{"id":15313876,"url":"https://github.com/itsdouges/react-scroll-store","last_synced_at":"2025-10-29T19:47:42.772Z","repository":{"id":57344262,"uuid":"100435987","full_name":"itsdouges/react-scroll-store","owner":"itsdouges","description":"📜 Stores scroll position on unmount and sets it back when the component is re-mounted.","archived":false,"fork":false,"pushed_at":"2017-08-16T02:13:44.000Z","size":70,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-26T01:41:54.453Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itsdouges.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-16T01:49:25.000Z","updated_at":"2018-09-24T11:11:51.000Z","dependencies_parsed_at":"2022-09-11T09:00:42.450Z","dependency_job_id":null,"html_url":"https://github.com/itsdouges/react-scroll-store","commit_stats":null,"previous_names":["madou/react-scroll-store"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdouges%2Freact-scroll-store","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdouges%2Freact-scroll-store/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdouges%2Freact-scroll-store/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itsdouges%2Freact-scroll-store/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itsdouges","download_url":"https://codeload.github.com/itsdouges/react-scroll-store/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241511220,"owners_count":19974375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T08:43:29.945Z","updated_at":"2025-10-29T19:47:42.663Z","avatar_url":"https://github.com/itsdouges.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [react-scroll-store](https://github.com/madou/react-scroll-store)\n\n[![NPM version](http://img.shields.io/npm/v/react-scroll-store.svg?style=flat-square)](https://www.npmjs.com/package/react-scroll-store)\n[![NPM downloads](http://img.shields.io/npm/dm/react-scroll-store.svg?style=flat-square)](https://www.npmjs.com/package/react-scroll-store)\n[![Build Status](http://img.shields.io/travis/madou/react-scroll-store/master.svg?style=flat-square)](https://travis-ci.org/madou/react-scroll-store)\n[![codecov](https://codecov.io/gh/madou/react-scroll-store/branch/master/graph/badge.svg)](https://codecov.io/gh/madou/react-scroll-store)\n[![Dependency Status](http://img.shields.io/david/madou/react-scroll-store.svg?style=flat-square)](https://david-dm.org/madou/react-scroll-store)\n\nStores scroll position on unmount and sets it back when the component is re-mounted.\n\n## Installation\n\n```sh\nnpm install react-scroll-store\n```\n\n## Usage\n\nImport the component factory, create the component, then use it.\n\n```javascript\nimport createScrollStore from 'react-scroll-store';\n\nconst RestoreScrollOnMount = createScrollStore();\n\nconst App = () =\u003e (\n  \u003cdiv\u003e\n    \u003cRestoreScrollOnMount /\u003e\n  \u003c/div\u003e\n);\n```\n\nWhen compontent did mount it will set the scroll position.\nWhen component will unmount it will store the scroll position.\n\nIf we have a more real example with `react-router`:\n\n```javascript\nconst App = () =\u003e (\n  \u003cdiv\u003e\n    \u003cRoute match=\"long-container\"\u003e\n      \u003cdiv className=\"really-long-container\"\u003e\n        \u003cRestoreScrollOnMount /\u003e\n        Best content\n\n        \u003cLink to=\"short-container\" /\u003e\n      \u003c/div\u003e\n    \u003c/Route\u003e\n\n    \u003cRoute match=\"short-container\"\u003e\n      \u003cdiv className=\"really-short-container\"\u003e\n        Cool content\n\n        \u003cLink to=\"long-container\" /\u003e\n      \u003c/div\u003e\n    \u003c/Route\u003e\n  \u003c/div\u003e\n);\n```\n\nWhen we visit `/long-container` the scroll position will be set when we unmount. We then visit `/short-container`, and then come back to `/long-container`. The scroll position that we were at when we left initially will now be set again.\n\n### React Story Book\n\nTo run the component in various modes, run the following command then go to `http://localhost:6006/`.\n\n```bash\nnpm start\n```\n\n### Testing\n\n```bash\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdouges%2Freact-scroll-store","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitsdouges%2Freact-scroll-store","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitsdouges%2Freact-scroll-store/lists"}