Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
Extended clear all props
Browse files Browse the repository at this point in the history
  • Loading branch information
dhmacs committed Oct 11, 2018
1 parent 9031475 commit 532bcb6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/Collection/ClearAllRefinements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type RenderProp = (context: IClearAllRefinementsContext) => React.ReactNode;

interface IProps {
children: RenderProp;
onClick?: (event: any) => void;
}

const ClearAllRefinementsConsumer: React.SFC<IProps> = props => {
Expand All @@ -35,7 +36,7 @@ const ClearAllRefinementsConsumer: React.SFC<IProps> = props => {

export default class ClearAllRefinements extends React.Component<IProps, {}> {
render() {
const { children } = this.props;
const { children, onClick, ...other } = this.props;
return (
<ClearAllRefinementsConsumer>
{context => {
Expand All @@ -44,7 +45,17 @@ export default class ClearAllRefinements extends React.Component<IProps, {}> {
}
if (context.hasRefinements) {
return (
<ClearAllButton onClick={context.clearAll}>
<ClearAllButton
onClick={
onClick
? event => {
onClick(event);
context.clearAll();
}
: context.clearAll
}
{...other}
>
{children}
</ClearAllButton>
);
Expand Down

0 comments on commit 532bcb6

Please sign in to comment.