react-code-dataset / next.js /test /development /pages-dir /client-navigation /fixture /pages /snap-scroll-position.js
Download next.js/test/development/pages-dir/client-navigation/fixture/pages/snap-scroll-position.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 579 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/pages-dir/client-navigation/fixture/pages/snap-scroll-position.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/test/development/pages-dir/client-navigation/fixture/pages/snap-scroll-position.js
-
curl -L -o snap-scroll-position.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/test/development/pages-dir/client-navigation/fixture/pages/snap-scroll-position.js
579 Bytes
| import React from 'react' | |
| export default class SnapScrollPosition extends React.Component { | |
| constructor(props) { | |
| super(props) | |
| this.state = { positionY: -1 } | |
| } | |
| componentDidMount() { | |
| this.setState({ positionY: window.scrollY }) | |
| } | |
| render() { | |
| return ( | |
| <main> | |
| {Array.from({ length: 500 }, (x, i) => i + 1).map((i) => { | |
| return ( | |
| <div key={`item-${i}`} id={`item-${i}`}> | |
| {i} | |
| </div> | |
| ) | |
| })} | |
| <span id="scroll-pos-y">{this.state.positionY}</span> | |
| </main> | |
| ) | |
| } | |
| } | |