Skip to content

Commit a91bc22

Browse files
committed
update libs, code cleanup, use npm
1 parent aa80a38 commit a91bc22

File tree

9 files changed

+13337
-21903
lines changed

9 files changed

+13337
-21903
lines changed

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"bracketSpacing": false,
33
"singleQuote": true,
44
"tabWidth": 4,
5-
"trailingComma": "es5"
5+
"arrowParens": "avoid"
66
}

demo/src/TestRow/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import React from 'react';
22

33
const TestRow = ({data, height, onClick, rowIndex, rowRef}) => (
44
<div ref={rowRef} className="test-row" onClick={() => onClick(rowIndex)}>
5-
<strong>[{data.id}]</strong>: {height}px<br/>{data.content}
5+
<strong>[{data.id}]</strong>: {height}px
6+
<br />
7+
{data.content}
68
</div>
79
);
810

demo/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import data from './data';
21
import React, {useState} from 'react';
2+
import data from './data';
33
import ReactSmartScroll from '../../src';
44
import {render} from 'react-dom';
55
import TestRow from './TestRow';

package-lock.json

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

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@
4444
},
4545
"dependencies": {},
4646
"peerDependencies": {
47-
"react": "^16.12.0"
47+
"react": "^16.13.1"
4848
},
4949
"devDependencies": {
50-
"babel-eslint": "^10.0.3",
50+
"babel-eslint": "^10.1.0",
5151
"eslint": "^6.8.0",
52-
"eslint-config-prettier": "^6.9.0",
53-
"eslint-config-react-app": "^5.1.0",
54-
"eslint-plugin-flowtype": "^4.5.3",
55-
"eslint-plugin-import": "^2.19.1",
52+
"eslint-config-prettier": "^6.10.1",
53+
"eslint-config-react-app": "^5.2.1",
54+
"eslint-plugin-flowtype": "^4.7.0",
55+
"eslint-plugin-import": "^2.20.2",
5656
"eslint-plugin-jsx-a11y": "^6.2.3",
5757
"eslint-plugin-prettier": "^3.1.2",
58-
"eslint-plugin-react": "^7.17.0",
59-
"eslint-plugin-react-hooks": "^2.3.0",
60-
"husky": "^4.0.3",
61-
"lint-staged": "^9.5.0",
62-
"nwb": "0.23.x",
63-
"prettier": "^1.19.1",
58+
"eslint-plugin-react": "^7.19.0",
59+
"eslint-plugin-react-hooks": "^3.0.0",
60+
"husky": "^4.2.3",
61+
"lint-staged": "^10.1.2",
62+
"nwb": "0.24.x",
63+
"prettier": "^2.0.4",
6464
"prop-types": "^15.7.2",
6565
"react": "^16.10.2",
66-
"react-dom": "^16.12.0"
66+
"react-dom": "^16.13.1"
6767
}
6868
}

src/ReactSmartScroll/index.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ const ReactSmartScroll = props => {
2626
} = props;
2727

2828
const [start, setStart] = useState(0);
29-
30-
const [refs, setRefs] = useState(
31-
Array(data.length)
32-
.fill(undefined)
33-
.map(() => createRef())
34-
);
29+
const [refs, setRefs] = useState([]);
3530

3631
const [actualHeights, setActualHeights] = useReducer((state, action) => {
3732
if (!action.reset) {
@@ -113,17 +108,7 @@ const ReactSmartScroll = props => {
113108
}, 0);
114109
}
115110
}
116-
}, [
117-
actualHeights,
118-
data,
119-
refs,
120-
scroll.top,
121-
setMeasurements,
122-
setStart,
123-
start,
124-
startAt,
125-
visible.height,
126-
]);
111+
}, [actualHeights, data, refs, scroll.top, start, startAt, visible.height]);
127112

128113
const {endIndex, paddingBottom, paddingTop, startIndex} = measurements;
129114

src/ReactSmartScroll/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// these utils are imperative because they are called in useLayoutEffect
2+
// and performance is the priority
13
export const calcStartIndex = (actualHeights, top = 0) => {
24
const len = actualHeights.length;
35
if (top === 0 || len < 2) return 0;

src/hooks/useScroll.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ export default ref => {
1010
left: current.scrollLeft,
1111
});
1212
};
13-
if (current) {
14-
current.addEventListener('scroll', onScroll);
15-
}
13+
if (current) current.addEventListener('scroll', onScroll);
1614
return () => current && current.removeEventListener('scroll', onScroll);
1715
}, [ref]);
1816
return scroll;

0 commit comments

Comments
 (0)