Skip to content

Commit e1ee12c

Browse files
committed
[1.1.0] version 1.1.0 of use-scroll-to-bottom
update create-react-library to version 3 change api to return a RefCallback instead of a Ref add tests to hook add tests to examples add 1 example with reusing the hook
1 parent 7fe762b commit e1ee12c

36 files changed

+20288
-18932
lines changed

.eslintignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
build/
2+
dist/
3+
node_modules/
4+
.snapshots/
5+
*.min.js
6+
*.d.ts

.eslintrc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"parser": "babel-eslint",
3+
"extends": [
4+
"standard",
5+
"standard-react",
6+
"plugin:prettier/recommended",
7+
"prettier/standard",
8+
"prettier/react"
9+
],
10+
"env": {
11+
"node": true
12+
},
13+
"parserOptions": {
14+
"ecmaVersion": 9,
15+
"ecmaFeatures": {
16+
"legacyDecorators": true,
17+
"jsx": true
18+
}
19+
},
20+
"settings": {
21+
"react": {
22+
"version": "16"
23+
}
24+
},
25+
"rules": {
26+
"space-before-function-paren": 0,
27+
"react/prop-types": 0,
28+
"react/jsx-handler-names": 0,
29+
"react/jsx-fragments": 0,
30+
"react/no-unused-prop-types": 0,
31+
"import/export": 0
32+
}
33+
}

.idea/codeStyles/Project.xml

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 425 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.prettier.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"singleQuote": true,
3+
"jsxSingleQuote": true,
4+
"semi": false,
5+
"tabWidth": 2,
6+
"bracketSpacing": true,
7+
"jsxBracketSameLine": false,
8+
"arrowParens": "always"
9+
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
3-
- 9
4-
- 8
3+
- 12
4+
- 10

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ npm install --save use-scroll-to-bottom
1313

1414
## Usage
1515

16+
The hook returns a tuple of two things:
17+
1. A RefCallback which needs to go on the last element of your scrolling container.
18+
2. A boolean value which tells you whether bottom has been reached or not.
19+
1620
Check [demo](https://tudorgergely.github.io/use-scroll-to-bottom/) and [examples](https://github.com/tudorgergely/use-scroll-to-bottom/tree/master/example)
1721

1822
```tsx
@@ -21,15 +25,15 @@ import {useScrollToBottom} from 'use-scroll-to-bottom'
2125

2226
export default function MyComponent() {
2327
// isBottom will be true when bottom is reached
24-
// add ref to an element right below your scrollable one
25-
const [ref, isBottom] = useScrollToBottom();
28+
// add setBottomRef to the last element in your scrolling container
29+
const [setBottomRef, isBottom] = useScrollToBottom();
2630

2731
return (
2832
<div className="simple-container">
2933
<div className="big-element">
3034
{isBottom && "Bottom reached"}
3135
</div>
32-
<div ref={ref}>Bottom</div>
36+
<div ref={setBottomRef}>Bottom</div>
3337
</div>
3438
)
3539
}

example/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### [Examples](https://tudorgergely.github.io/use-scroll-to-bottom/)
2+
3+
4+
#### To see examples:
5+
> npm i
6+
7+
> npm start
8+
9+
Open localhost:3000 to see the examples
10+
11+
12+
####To run tests on examples:
13+
> npm test
14+

0 commit comments

Comments
 (0)