Skip to content

Commit aa52623

Browse files
committed
Remove superfluous key prop
#177 The key prop is defined and handled by React and does not need to be seperately handled here. Including key as a prop introduces a runtime warning.
1 parent c115356 commit aa52623

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ added. An infinite-scroll that actually works and super-simple to integrate!
66
# install
77
```bash
88
npm install --save react-infinite-scroll-component
9-
9+
1010
or
11-
12-
yarn add react-infinite-scroll-component
11+
12+
yarn add react-infinite-scroll-component
1313

1414
// in code ES6
1515
import InfiniteScroll from 'react-infinite-scroll-component';
@@ -74,7 +74,7 @@ name | type | description
7474
**dataLength** | number | set the length of the data.This will unlock the subsequent calls to next.
7575
**loader** | node | you can send a loader component to show while the component waits for the next load of data. e.g. `<h3>Loading...</h3>` or any fancy loader element
7676
**scrollThreshold** | number &#124; string | A threshold value defining when `InfiniteScroll` will call `next`. Default value is `0.8`. It means the `next` will be called when user comes below 80% of the total height. If you pass threshold in pixels (`scrollThreshold="200px"`), `next` will be called once you scroll at least (100% - scrollThreshold) pixels down.
77-
**onScroll** | function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect.
77+
**onScroll** | function | a function that will listen to the scroll event on the scrolling container. Note that the scroll event is throttled, so you may not receive as many events as you would expect.
7878
**endMessage** | node | this message is shown to the user when he has seen all the records which means he's at the bottom and `hasMore` is `false`
7979
**className** | string | add any custom class you want
8080
**style** | object | any style which you want to override
@@ -87,4 +87,3 @@ name | type | description
8787
**pullDownToRefreshThreshold** | number | minimum distance the user needs to pull down to trigger the refresh, `default=100px` , a lower value may be needed to trigger the refresh depending your users browser.
8888
**refreshFunction** | function | this function will be called, it should return the fresh data that you want to show the user
8989
**initialScrollY** | number | set a scroll y position for the component to render with.
90-
**key** | string | the key for the current data set being shown, used when the same component can show different data sets at different times, `default=undefined`

src/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface Props {
2222
onScroll?: (e: MouseEvent) => any;
2323
dataLength: number;
2424
initialScrollY?: number;
25-
key?: string;
2625
className?: string;
2726
}
2827

@@ -138,11 +137,8 @@ export default class InfiniteScroll extends Component<Props, State> {
138137
}
139138

140139
UNSAFE_componentWillReceiveProps(props: Props) {
141-
// do nothing when dataLength and key are unchanged
142-
if (
143-
this.props.key === props.key &&
144-
this.props.dataLength === props.dataLength
145-
)
140+
// do nothing when dataLength is unchanged
141+
if (this.props.dataLength === props.dataLength)
146142
return;
147143

148144
this.actionTriggered = false;

0 commit comments

Comments
 (0)