virtual-scroller 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  <!-- `virtual-scroller`: in `.updateItems()` handle a case when `items.length` is the same, in which case find different items and if those items are rendered then maybe update them on screen and update their height, if the items are past rendered then maybe just discard all item heights past rendered, if the items are before rendered then maybe ignore and it will jump on scroll up which is kinda acceptable. -->
2
2
 
3
+ 1.10.0 / 22.11.2022
4
+ ==================
5
+
6
+ * [React] Applied TypeScript [props fixes](https://gitlab.com/catamphetamine/virtual-scroller/-/merge_requests/1).
7
+
8
+ * [React] Added two new properties: `item` and [`itemIndex`](https://gitlab.com/catamphetamine/virtual-scroller/-/issues/26). The legacy `children` property is still passed but is considered deprecated.
9
+
3
10
  1.9.0 / 18.05.2022
4
11
  ==================
5
12
 
package/README.md CHANGED
@@ -451,7 +451,9 @@ The required properties are:
451
451
 
452
452
  * `itemComponent` — List item React component.
453
453
 
454
- * The `itemComponent` will receive a `children` property which is gonna be the item object itself (an element of the `items` array).
454
+ * The `itemComponent` will receive properties:
455
+ * `item` — the item object itself (an element of the `items` array).
456
+ * `itemIndex: number` — the index of the item object in the `items` array.
455
457
 
456
458
  * For best performance, make sure that `itemComponent` is a `React.memo()` component or a `React.PureComponent`. Otherwise, list items will keep re-rendering themselves as the user scrolls because the containing `<VirtualScroller/>` component gets re-rendered on scroll.
457
459
 
@@ -471,7 +473,7 @@ function Messages({ messages }) {
471
473
  )
472
474
  }
473
475
 
474
- function Message({ children: message }) {
476
+ function Message({ item: message }) {
475
477
  const {
476
478
  username,
477
479
  date,
@@ -503,7 +505,7 @@ Messages.propTypes = {
503
505
  }
504
506
 
505
507
  Message.propTypes = {
506
- children: message.isRequired
508
+ item: message.isRequired
507
509
  }
508
510
  ```
509
511
 
@@ -541,7 +543,7 @@ function ItemComponent({
541
543
  state: savedState,
542
544
  onStateChange,
543
545
  onHeightChange,
544
- children: item
546
+ item
545
547
  }) {
546
548
  const [state, setState] = useState(savedState)
547
549