Skip to content

Commit

Permalink
fix: fix example filtered data
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrylo Hudym-Levkovych authored and Kyrylo Hudym-Levkovych committed Sep 6, 2023
1 parent 0ef92d9 commit 8c6e23d
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions src/DataTable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,20 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
famous_for: 'modeling',
},
], [])
const reducedChoices = data.reduce((acc, currentObject) => {
const { color } = currentObject;
if (color in acc) {
color.number += 1;
} else {
acc[color] = {
name: color,
number: 1,
value: color,
};
}
return acc;
}, {});

return (
<DataTable
isFilterable
Expand All @@ -371,7 +385,7 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
}}
isSortable
defaultColumnValues={{ Filter: TextFilter }}
itemCount={3}
itemCount={data.length}
data={data}
columns={[
{
Expand All @@ -387,26 +401,7 @@ See ``dataViewToggleOptions`` props documentation for all supported props.
accessor: 'color',
Filter: CheckboxFilter,
filter: 'includesValue',
filterChoices: [{
name: 'russian white',
number: 1,
value: 'russian white',
},
{
name: 'orange tabby',
number: 2,
value: 'orange tabby',
},
{
name: 'brown tabby',
number: 3,
value: 'brown tabby',
},
{
name: 'siamese',
number: 1,
value: 'siamese',
}]
filterChoices: Object.values(reducedChoices),
},
]}
>
Expand Down

0 comments on commit 8c6e23d

Please sign in to comment.