Skip to content

Commit b8eae68

Browse files
chore(release): 3.6.1
## [3.6.1](v3.6.0...v3.6.1) (2021-10-23) ### Bug Fixes * **use-scroller:** unsubscribe from updates when hook has unmounted ([#97](#97)) ([2117625](2117625))
1 parent 2117625 commit b8eae68

13 files changed

+78
-19
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [3.6.1](https://github.com/jaredLunde/masonic/compare/v3.6.0...v3.6.1) (2021-10-23)
2+
3+
### Bug Fixes
4+
5+
- **use-scroller:** unsubscribe from updates when hook has unmounted ([#97](https://github.com/jaredLunde/masonic/issues/97)) ([2117625](https://github.com/jaredLunde/masonic/commit/2117625fb14b27b5f33a3a8121cbb83a62de5b5c))
6+
17
# Changelog
28

39
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "masonic",
3-
"version": "3.6.0",
3+
"version": "3.6.1",
44
"description": "",
55
"license": "MIT",
66
"author": "Jared Lunde <jared.lunde@gmail.com> (https://jaredlunde.com/)",

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
export * from "./interval-tree";
12
export * from "./list";
23
export * from "./masonry";
34
export * from "./masonry-scroller";
@@ -8,4 +9,3 @@ export * from "./use-positioner";
89
export * from "./use-resize-observer";
910
export * from "./use-scroll-to-index";
1011
export * from "./use-scroller";
11-
export * from "./interval-tree";

types/list.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import type { MasonryProps } from "./masonry";
33
/**
44
* This is just a single-column `<Masonry>` component without column-specific props.
5+
*
6+
* @param props
57
*/
68
export declare function List<Item>(props: ListProps<Item>): JSX.Element;
79
export declare namespace List {
@@ -14,6 +16,7 @@ export interface ListProps<Item>
1416
> {
1517
/**
1618
* The amount of vertical space in pixels to add between the list cells.
19+
*
1720
* @default 0
1821
*/
1922
rowGutter?: number;

types/masonry-scroller.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { UseMasonryOptions } from "./use-masonry";
33
/**
44
* A heavily-optimized component that updates `useMasonry()` when the scroll position of the browser `window`
55
* changes. This bare-metal component is used by `<Masonry>` under the hood.
6+
*
7+
* @param props
68
*/
79
export declare function MasonryScroller<Item>(
810
props: MasonryScrollerProps<Item>
@@ -17,12 +19,14 @@ export interface MasonryScrollerProps<Item>
1719
* browser `window` in state, and as a result the rate the masonry grid recalculates its visible cells.
1820
* The default value of `12` has been very reasonable in my own testing, but if you have particularly
1921
* heavy `render` components it may be prudent to reduce this number.
22+
*
2023
* @default 12
2124
*/
2225
scrollFps?: number;
2326
/**
2427
* The vertical space in pixels between the top of the grid container and the top
2528
* of the browser `document.documentElement`.
29+
*
2630
* @default 0
2731
*/
2832
offset?: number;

types/masonry.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import type { UseScrollToIndexOptions } from "./use-scroll-to-index";
77
* easiest way to get off and running in your app, before switching to more advanced implementations, if necessary.
88
* It will change its column count to fit its container's width and will decide how many rows to render based upon
99
* the height of the browser `window`.
10+
*
11+
* @param props
1012
*/
1113
export declare function Masonry<Item>(
1214
props: MasonryProps<Item>
@@ -48,6 +50,7 @@ export interface MasonryProps<Item>
4850
* browser `window` in state, and as a result the rate the masonry grid recalculates its visible cells.
4951
* The default value of `12` has been very reasonable in my own testing, but if you have particularly
5052
* heavy `render` components it may be prudent to reduce this number.
53+
*
5154
* @default 12
5255
*/
5356
scrollFps?: number;

types/use-container-position.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import * as React from "react";
44
* from the top of the document. These values are necessary to correctly calculate the number/width
55
* of columns to render, as well as the number of rows to render.
66
*
7-
* @param elementRef A `ref` object created by `React.useRef()`. That ref should be provided to the
7+
* @param elementRef - A `ref` object created by `React.useRef()`. That ref should be provided to the
88
* `containerRef` property in `useMasonry()`.
9-
* @param deps You can force this hook to recalculate the `offset` and `width` whenever this
9+
* @param deps - You can force this hook to recalculate the `offset` and `width` whenever this
1010
* dependencies list changes. A common dependencies list might look like `[windowWidth, windowHeight]`,
1111
* which would force the hook to recalculate any time the size of the browser `window` changed.
1212
*/

types/use-infinite-loader.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* hook invokes a callback each time the last rendered index surpasses the total number of items
44
* in your items array or the number defined in the `totalItems` option.
55
*
6-
* @param loadMoreItems This callback is invoked when more rows must be loaded. It will be used to
6+
* @param loadMoreItems - This callback is invoked when more rows must be loaded. It will be used to
77
* determine when to refresh the list with the newly-loaded data. This callback may be called multiple
88
* times in reaction to a single scroll event, so it's important to memoize its arguments. If you're
99
* creating this callback inside of a functional component, make sure you wrap it in `React.useCallback()`,
@@ -21,24 +21,28 @@ export interface UseInfiniteLoaderOptions<Item> {
2121
/**
2222
* A callback responsible for determining the loaded state of each item. Should return `true`
2323
* if the item has already been loaded and `false` if not.
24+
*
2425
* @default (index: number, items: any[]) => boolean
2526
*/
2627
isItemLoaded?: (index: number, items: Item[]) => boolean;
2728
/**
2829
* The minimum number of new items to be loaded at a time. This property can be used to
2930
* batch requests and reduce HTTP requests.
31+
*
3032
* @default 16
3133
*/
3234
minimumBatchSize?: number;
3335
/**
3436
* The threshold at which to pre-fetch data. A threshold X means that new data should start
3537
* loading when a user scrolls within X cells of the end of your `items` array.
38+
*
3639
* @default 16
3740
*/
3841
threshold?: number;
3942
/**
4043
* The total number of items you'll need to eventually load (if known). This can
4144
* be arbitrarily high if not known.
45+
*
4246
* @default 9e9
4347
*/
4448
totalItems?: number;

types/use-masonry.d.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,27 @@ import type { Positioner } from "./use-positioner";
33
/**
44
* This hook handles the render phases of the masonry layout and returns the grid as a React element.
55
*
6-
* @param options Options for configuring the masonry layout renderer. See `UseMasonryOptions`.
6+
* @param options - Options for configuring the masonry layout renderer. See `UseMasonryOptions`.
7+
* @param options.positioner
8+
* @param options.resizeObserver
9+
* @param options.items
10+
* @param options.as
11+
* @param options.id
12+
* @param options.className
13+
* @param options.style
14+
* @param options.role
15+
* @param options.tabIndex
16+
* @param options.containerRef
17+
* @param options.itemAs
18+
* @param options.itemStyle
19+
* @param options.itemHeightEstimate
20+
* @param options.itemKey
21+
* @param options.overscanBy
22+
* @param options.scrollTop
23+
* @param options.isScrolling
24+
* @param options.height
25+
* @param options.render
26+
* @param options.onRender
727
*/
828
export declare function useMasonry<Item>({
929
positioner,
@@ -49,6 +69,7 @@ export interface UseMasonryOptions<Item> {
4969
};
5070
/**
5171
* This is the type of element the grid container will be rendered as.
72+
*
5273
* @default "div"`
5374
*/
5475
as?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
@@ -67,11 +88,13 @@ export interface UseMasonryOptions<Item> {
6788
style?: React.CSSProperties;
6889
/**
6990
* Optionally swap out the accessibility `role` prop of the container and its items.
91+
*
7092
* @default "grid"
7193
*/
7294
role?: "grid" | "list";
7395
/**
7496
* Change the `tabIndex` of the grid container.
97+
*
7598
* @default 0
7699
*/
77100
tabIndex?: number;
@@ -83,6 +106,7 @@ export interface UseMasonryOptions<Item> {
83106
| React.MutableRefObject<HTMLElement | null>;
84107
/**
85108
* This is the type of element the grid items will be rendered as.
109+
*
86110
* @default "div"
87111
*/
88112
itemAs?: keyof JSX.IntrinsicElements | React.ComponentType<any>;
@@ -95,6 +119,7 @@ export interface UseMasonryOptions<Item> {
95119
* This value is used for estimating the initial height of the masonry grid. It is important for
96120
* the UX of the scrolling behavior and in determining how many `items` to render in a batch, so it's
97121
* wise to set this value with some level accuracy, though it doesn't need to be perfect.
122+
*
98123
* @default 300
99124
*/
100125
itemHeightEstimate?: number;
@@ -103,6 +128,7 @@ export interface UseMasonryOptions<Item> {
103128
* if your collection of items is never modified. Setting this property ensures that the component in `render`
104129
* is reused each time the masonry grid is reflowed. A common pattern would be to return the item's database
105130
* ID here if there is one, e.g. `data => data.id`
131+
*
106132
* @default (data, index) => index`
107133
*/
108134
itemKey?: (data: Item, index: number) => string | number;
@@ -116,6 +142,7 @@ export interface UseMasonryOptions<Item> {
116142
* too high of a vaimport { useForceUpdate } from './use-force-update';
117143
lue may create too much work for React to handle, so it's best that you tune this
118144
* value accordingly.
145+
*
119146
* @default 2
120147
*/
121148
overscanBy?: number;
@@ -140,6 +167,7 @@ export interface UseMasonryOptions<Item> {
140167
* `will-change: contents;` value to the style string. You can forgo using this prop, but I would
141168
* not recommend that. The `useScroller()` hook and `<MasonryScroller>` components will help you if
142169
* you're rendering the grid relative to the browser `window`.
170+
*
143171
* @default false
144172
*/
145173
isScrolling?: boolean;

types/use-positioner.d.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ import * as React from "react";
44
* the meat of the grid's layout algorithm, determining which cells to render at a given scroll
55
* position, as well as where to place new items in the grid.
66
*
7-
* @param options Properties that determine the number of columns in the grid, as well
7+
* @param options - Properties that determine the number of columns in the grid, as well
88
* as their widths.
9-
* @param deps This hook will create a new positioner, clearing all existing cached positions,
9+
* @param options.columnWidth
10+
* @param options.width
11+
* @param deps - This hook will create a new positioner, clearing all existing cached positions,
1012
* whenever the dependencies in this list change.
13+
* @param options.columnGutter
14+
* @param options.rowGutter
15+
* @param options.columnCount
1116
*/
1217
export declare function usePositioner(
1318
{
@@ -30,12 +35,14 @@ export interface UsePositionerOptions {
3035
* columns to fill their container based upon the `columnWidth` and `columnGutter` values.
3136
* It will never render anything smaller than this width unless its container itself is
3237
* smaller than its value. This property is optional if you're using a static `columnCount`.
38+
*
3339
* @default 200
3440
*/
3541
columnWidth?: number;
3642
/**
3743
* This sets the horizontal space between grid columns in pixels. If `rowGutter` is not set, this
3844
* also sets the vertical space between cells within a column in pixels.
45+
*
3946
* @default 0
4047
*/
4148
columnGutter?: number;
@@ -55,10 +62,10 @@ export interface UsePositionerOptions {
5562
* Creates a cell positioner for the `useMasonry()` hook. The `usePositioner()` hook uses
5663
* this utility under the hood.
5764
*
58-
* @param columnCount The number of columns in the grid
59-
* @param columnWidth The width of each column in the grid
60-
* @param columnGutter The amount of horizontal space between columns in pixels.
61-
* @param rowGutter The amount of vertical space between cells within a column in pixels (falls back
65+
* @param columnCount - The number of columns in the grid
66+
* @param columnWidth - The width of each column in the grid
67+
* @param columnGutter - The amount of horizontal space between columns in pixels.
68+
* @param rowGutter - The amount of vertical space between cells within a column in pixels (falls back
6269
* to `columnGutter`).
6370
*/
6471
export declare const createPositioner: (

0 commit comments

Comments
 (0)