@@ -43,7 +43,7 @@ import {
4343- [ Accessibility Considerations] ( #accessibility-considerations )
4444 - [ Accessible Name] ( #accessible-name )
4545- [ Props] ( #props )
46- - [ Render props ] ( #render-props )
46+ - [ Render function ] ( #render-function )
4747 - [ Prop getters] ( #prop-getters )
4848 - [ Actions] ( #actions )
4949 - [ State] ( #state )
@@ -119,7 +119,14 @@ writing:
119119
120120``` jsx
121121< DataTable rows= {rows} headers= {headers}>
122- {({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
122+ {({
123+ rows,
124+ headers,
125+ getTableProps,
126+ getHeaderProps,
127+ getRowProps,
128+ getCellProps,
129+ }) => (
123130 < Table {... getTableProps ()}>
124131 < TableHead>
125132 < TableRow>
@@ -134,7 +141,7 @@ writing:
134141 {rows .map ((row ) => (
135142 < TableRow {... getRowProps ({ row })}>
136143 {row .cells .map ((cell ) => (
137- < TableCell key = { cell . id }> {cell .value }< / TableCell>
144+ < TableCell { ... getCellProps ({ cell }) }> {cell .value }< / TableCell>
138145 ))}
139146 < / TableRow>
140147 ))}
@@ -173,9 +180,9 @@ some table column headers, but not all.
173180
174181In addition to the prop getter specified in the previous section, you can also
175182change the sort status of the table by using the ` sortBy ` action made available
176- in your ` render ` prop function . This ` sortBy ` utility takes in the ` key ` of the
177- header you want to sort by as an argument. After invoking this method with the
178- given ` key ` , the table should be sorted by the header that you've specified.
183+ in your ` children ` prop. This ` sortBy ` utility takes in the ` key ` of the header
184+ you want to sort by as an argument. After invoking this method with the given
185+ ` key ` , the table should be sorted by the header that you've specified.
179186
180187### Custom sorting
181188
@@ -205,7 +212,7 @@ function customSortRow(cellA, cellB, { sortDirection, sortStates, locale }) {
205212
206213## Expansion
207214
208- The ` DataTable ` components supports row-level expansion when combined with the
215+ The ` DataTable ` component supports row-level expansion when combined with the
209216` TableExpandHeader ` , ` TableExpandRow ` , and ` TableExpandedRow ` components.
210217
211218<Canvas id = " components-datatable-expansion--default" />
@@ -222,7 +229,7 @@ has the necessary props.
222229
223230### Programmatic expansion
224231
225- You can use the ` expandRow ` action made available through your ` render ` prop
232+ You can use the ` expandRow ` action made available through your ` children ` prop
226233function to toggle the expansion state of a given row. This method takes in the
227234row id as a single argument.
228235
@@ -244,12 +251,12 @@ cells in a row. It also uses `getSelectionProps` props, but also takes in the
244251current ` row ` in order to retrieve selection state about the given row.
245252
246253You can access all the selected rows through the ` selectedRows ` property passed
247- into your ` render ` prop function.
254+ into your ` children ` prop function.
248255
249256### Programmatic selection
250257
251- You can use either of the following actions from your ` render ` prop function to
252- update the selection status of a row:
258+ You can use either of the following actions from your ` children ` prop function
259+ to update the selection status of a row:
253260
254261- ` selectAll ` : invoking this will toggle the selection of all rows, either by
255262 making all selected or de-selecting all rows
@@ -259,18 +266,19 @@ update the selection status of a row:
259266## Filtering
260267
261268Filtering in a ` DataTable ` is provided through usage of the ` TableToolbar ` and
262- the ` TableToolbarSearch ` component. Any input entered through
263- ` TableToolbarSearch ` will be used when the ` filterRows ` prop is applied
269+ the ` TableToolbarSearch ` component. By default, filtering is handled by a
270+ built-in ` filterRows ` implementation. You can customize filtering behavior by
271+ passing your own ` filterRows ` function as a prop.
264272
265273By default ` filterRows ` is provided through our default implementation. However,
266274you can provide your own method if needed.
267275
268276<Canvas id = " components-datatable-filtering--default" />
269277
270278In order to integrate filtering into your data table, you will need to provide
271- the ` onInputChange ` function provided to you from ` DataTable ` 's render prop and
272- pass it to the ` onChange ` prop of ` TableToolbarSearch ` in your ` TableToolbar `
273- component.
279+ the ` onInputChange ` function provided to you from ` DataTable ` 's ` children ` prop
280+ and pass it to the ` onChange ` prop of ` TableToolbarSearch ` in your
281+ ` TableToolbar ` component.
274282
275283### Multiple filters with batch updates
276284
@@ -333,9 +341,9 @@ const handleOnResetFilter = () => {
333341Finally, pass the array of rows from the ` useState ` into the DataTable.
334342
335343``` jsx
336- < DataTable rows= {renderedRows} headers= {headers}>
337- ...
338- < / Datatable >
344+ < DataTable rows= {renderedRows} headers= {headers}>
345+ // ...
346+ < / DataTable >
339347```
340348
341349## Batch actions
@@ -370,9 +378,9 @@ cell.
370378``` jsx
371379< TableBody>
372380 {rows .map ((row ) => (
373- < TableRow key = { row . id } {... getRowProps ({ row })}>
381+ < TableRow {... getRowProps ({ row })}>
374382 {row .cells .map ((cell ) => (
375- < TableCell key = { cell . id }> {cell .value }< / TableCell>
383+ < TableCell { ... getCellProps ({ cell }) }> {cell .value }< / TableCell>
376384 ))}
377385 < TableCell className= " cds--table-column-menu" >
378386 < OverflowMenu size= " sm" flipped>
@@ -491,24 +499,23 @@ naming rule
491499
492500<ArgTypes />
493501
494- ### Render props
502+ ### Render function
495503
496- The ` DataTable ` component uses a render props pattern to give you full control
497- over rendering, while Carbon manages internal state like sorting, filtering,
498- selection, and expansion.
504+ The ` DataTable ` component uses a render function passed via the ` children ` prop
505+ to give you full control over how your table is rendered, while Carbon manages
506+ internal state like sorting, filtering, selection, and expansion.
499507
500- You can pass either a ` render ` or ` children ` function as a prop. This function
501- receives an object with the following properties :
508+ The function you provide to the ` children ` prop receives a render props object
509+ with access to :
502510
503511- [ Prop getters] ( #prop-getters )
504512- [ Actions] ( #actions )
505513- [ State] ( #state )
506514
507515#### Prop getters
508516
509- These functions are provided via the ` DataTable ` 's render props and must be
510- applied to the corresponding Carbon components to enable built-in functionality
511- like sorting, selection, and expansion.
517+ These functions must be applied to the corresponding components to enable
518+ built-in functionality like sorting, selection, and expansion.
512519
513520| Getter | Description |
514521| ------------------------ | ----------------------------------------------------------------- |
@@ -529,7 +536,7 @@ the `DataTableRenderProps` type in the
529536
530537#### Actions
531538
532- These functions allow you to programmatically update the table's state.
539+ These functions allow you to programmatically update the table's internal state.
533540
534541| Action | Description |
535542| --------------- | ----------------------------------------- |
@@ -581,9 +588,7 @@ conditional rendering.
581588 < TableRow {... getRowProps ({ row })}>
582589 < TableSelectRow {... getSelectionProps ({ row })} / >
583590 {row .cells .map ((cell ) => (
584- < TableCell key= {cell .id } {... getCellProps ({ cell })}>
585- {cell .value }
586- < / TableCell>
591+ < TableCell {... getCellProps ({ cell })}> {cell .value }< / TableCell>
587592 ))}
588593 < / TableRow>
589594 ))}
0 commit comments