Skip to content

Commit

Permalink
Removed from the example useMemo, propTypes, also simplified the exam…
Browse files Browse the repository at this point in the history
…ple.
  • Loading branch information
Artexoid committed Jan 22, 2020
1 parent 95dc82c commit a9a9368
Showing 1 changed file with 28 additions and 49 deletions.
77 changes: 28 additions & 49 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,66 +99,45 @@ const ListActions = ({
resource,
filters,
displayedFilters,
exporter,
exporter, // you can hide ExportButton if exporter = (null || false)
filterValues,
permanentFilter,
hasCreate,
hasCreate, // you can hide CreateButton if hasCreate = false
basePath,
selectedIds,
onUnselectItems,
showFilter,
maxResults,
total,
...rest
}) => useMemo(
() => (
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
{filters && cloneElement(filters, {
resource,
showFilter,
displayedFilters,
filterValues,
context: 'button',
})}
{hasCreate && <CreateButton basePath={basePath} />}
{exporter !== false && (
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={{ ...filterValues, ...permanentFilter }}
exporter={exporter}
maxResults={maxResults}
/>
)}
{/* Add your custom actions */}
<Button
onClick={() => { alert('Your custom action'); }}
label="Show calendar"
>
<IconEvent />
</Button>
</TopToolbar>
),
[resource, displayedFilters, filterValues, selectedIds, filters, total],
}) => (
<TopToolbar className={className} {...sanitizeListRestProps(rest)}>
{filters && cloneElement(filters, {
resource,
showFilter,
displayedFilters,
filterValues,
context: 'button',
})}
<CreateButton basePath={basePath} />
<ExportButton
disabled={total === 0}
resource={resource}
sort={currentSort}
filter={{ ...filterValues, ...permanentFilter }}
exporter={exporter}
maxResults={maxResults}
/>
{/* Add your custom actions */}
<Button
onClick={() => { alert('Your custom action'); }}
label="Show calendar"
>
<IconEvent />
</Button>
</TopToolbar>
);

ListActions.propTypes = {
basePath: PropTypes.string,
className: PropTypes.string,
currentSort: PropTypes.shape({}),
displayedFilters: PropTypes.shape({}),
exporter: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
filters: PropTypes.element,
filterValues: PropTypes.shape({}),
hasCreate: PropTypes.bool,
resource: PropTypes.string,
onUnselectItems: PropTypes.func.isRequired,
selectedIds: PropTypes.arrayOf(PropTypes.any),
showFilter: PropTypes.func,
total: PropTypes.number,
};

ListActions.defaultProps = {
selectedIds: [],
onUnselectItems: () => null,
Expand Down

0 comments on commit a9a9368

Please sign in to comment.