Skip to content

Commit 40dba07

Browse files
committed
Export the defaultCellRangeRenderer used by Grid in order to enable easier composition.
1 parent 34dcefa commit 40dba07

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
------------
33

4+
##### 7.7.1
5+
Export the `defaultCellRangeRenderer` used by `Grid` in order to enable easier composition.
6+
47
##### 7.7.0
58
Added configurable `tabIndex` property to `Grid`, `FlexTable`, and `VirtualScroll`.
69
Default value remains 0 but can now be overridden.

docs/Grid.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,34 @@ The Grid component supports the following static class names
6464
This is an advanced property.
6565
It is useful for situations where the `Grid` requires additional, overlayed UI (such as a Gantt chart or a calendar application).
6666
Many use cases can be solved more easily using the `onScroll` callback or the `ScrollSync` HOC.
67-
If you do choose to implement your own range renderer though, consider starting by forking the [`defaultCellRangeRenderer`](https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/defaultCellRangeRenderer.js) function.
6867

69-
The general shape of your range renderer function should look something like the following:
68+
If you do want to override `cellRangeRenderer` the easiest way is to decorate the default implementation like so:
69+
70+
```js
71+
import { defaultCellRangeRenderer, Grid } from '../'
72+
73+
function cellRangeRenderer (props) {
74+
const children = defaultCellRangeRenderer(props)
75+
children.push(
76+
<div>My custom overlay</div>
77+
)
78+
return children
79+
}
80+
81+
function CustomizedGrid (props) {
82+
return (
83+
<Grid
84+
cellRangeRenderer={cellRangeRenderer}
85+
{...props}
86+
/>
87+
)
88+
}
89+
```
90+
91+
92+
If you require greater customization, you may want to fork the [`defaultCellRangeRenderer`](https://github.com/bvaughn/react-virtualized/blob/master/source/Grid/defaultCellRangeRenderer.js) function.
93+
94+
This function accepts the following named parameters:
7095

7196
```js
7297
function cellRangeRenderer ({
@@ -112,7 +137,6 @@ function cellRangeRenderer ({
112137

113138
return renderedCells
114139
}
115-
}
116140
```
117141

118142
### Examples

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "React components for efficiently rendering large, scrollable lists and tabular data",
44
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
55
"user": "bvaughn",
6-
"version": "7.7.0",
6+
"version": "7.7.1",
77
"homepage": "https://github.com/bvaughn/react-virtualized",
88
"main": "dist/commonjs/index.js",
99
"jsnext:main": "dist/es/index.js",

source/Grid/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/** @flow */
22
export default from './Grid'
33
export Grid from './Grid'
4+
export defaultCellRangeRenderer from './defaultCellRangeRenderer'

source/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ export { AutoSizer } from './AutoSizer'
44
export { CellMeasurer } from './CellMeasurer'
55
export { Collection } from './Collection'
66
export { ColumnSizer } from './ColumnSizer'
7-
export { FlexTable, FlexColumn, SortDirection, SortIndicator } from './FlexTable'
8-
export { Grid } from './Grid'
7+
export {
8+
FlexTable,
9+
FlexColumn,
10+
SortDirection,
11+
SortIndicator
12+
} from './FlexTable'
13+
export {
14+
defaultCellRangeRenderer,
15+
Grid
16+
} from './Grid'
917
export { InfiniteLoader } from './InfiniteLoader'
1018
export { ScrollSync } from './ScrollSync'
1119
export { VirtualScroll } from './VirtualScroll'

0 commit comments

Comments
 (0)