File tree Expand file tree Collapse file tree 3 files changed +49
-19
lines changed
Expand file tree Collapse file tree 3 files changed +49
-19
lines changed Original file line number Diff line number Diff line change 1- import 'react-app-polyfill/ie11' ;
2- import * as React from 'react' ;
3- import * as ReactDOM from 'react-dom' ;
1+ import "react-app-polyfill/ie11" ;
2+ import * as ReactDOM from "react-dom" ;
3+ import React , { useRef } from "react" ;
4+ import { useSmoothScroll } from "react-smooth-scroll-hook" ;
5+ export default function App ( ) {
6+ const ref = useRef ( null ) ;
7+ const { scrollTo } = useSmoothScroll ( {
8+ ref
9+ } ) ;
10+ return (
11+ < div className = "App" >
12+ < h1 > react-smooth-scroll-hook</ h1 >
13+ < button onClick = { ( ) => scrollTo ( "#item-10" ) } > scrollTo("#item-10")</ button >
14+ < button onClick = { ( ) => scrollTo ( Infinity ) } > scrollTo(Infinity)</ button >
15+ < button onClick = { ( ) => scrollTo ( - Infinity ) } > scrollTo(-Infinity)</ button >
16+ < br />
17+ < div
18+ ref = { ref }
19+ style = { {
20+ overflowY : "scroll" ,
21+ maxHeight : "400px"
22+ } }
23+ >
24+ { Array ( 100 )
25+ . fill ( null )
26+ . map ( ( _item , i ) => (
27+ < div key = { i } id = { `item-${ i } ` } >
28+ { i }
29+ </ div >
30+ ) ) }
31+ </ div >
32+ </ div >
33+ ) ;
34+ }
435
5- const App = ( ) => {
6- return < div > </ div > ;
7- } ;
8-
9- ReactDOM . render ( < App /> , document . getElementById ( 'root' ) ) ;
36+ ReactDOM . render ( < App /> , document . getElementById ( "root" ) ) ;
Original file line number Diff line number Diff line change 88 "build" : " parcel build index.html"
99 },
1010 "dependencies" : {
11- "react-app-polyfill" : " ^1.0.0"
12- },
13- "alias" : {
14- "react" : " ../node_modules/react" ,
15- "react-dom" : " ../node_modules/react-dom/profiling" ,
16- "scheduler/tracing" : " ../node_modules/scheduler/tracing-profiling"
11+ "@types/node" : " 14.6.0" ,
12+ "react" : " 16.13.1" ,
13+ "react-app-polyfill" : " ^1.0.0" ,
14+ "react-dom" : " 16.13.1" ,
15+ "react-smooth-scroll-hook" : " 1.2.0"
1716 },
1817 "devDependencies" : {
1918 "@types/react" : " ^16.9.11" ,
2019 "@types/react-dom" : " ^16.8.4" ,
2120 "parcel" : " ^1.12.3" ,
2221 "typescript" : " ^3.4.5"
2322 }
24- }
23+ }
Original file line number Diff line number Diff line change 11{
22 "compilerOptions" : {
3- "allowSyntheticDefaultImports" : false ,
43 "target" : " es5" ,
54 "module" : " commonjs" ,
65 "jsx" : " react" ,
1211 "strictNullChecks" : true ,
1312 "preserveConstEnums" : true ,
1413 "sourceMap" : true ,
15- "lib" : [" es2015" , " es2016" , " dom" ],
14+ "lib" : [
15+ " es2015" ,
16+ " es2016" ,
17+ " dom"
18+ ],
1619 "baseUrl" : " ." ,
17- "types" : [" node" ]
20+ "esModuleInterop" : true ,
21+ "allowSyntheticDefaultImports" : true
1822 }
19- }
23+ }
You can’t perform that action at this time.
0 commit comments