Skip to content

Commit

Permalink
Fixes #99 - Add displayName to components exported by withSnackbar
Browse files Browse the repository at this point in the history
  • Loading branch information
iamhosseindhv committed Mar 26, 2019
1 parent fcc6ad0 commit e88d073
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/withSnackbar.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import { SnackbarContext, SnackbarContextNext } from './SnackbarContext';

const withSnackbar = (WrappedComponent) => {
const Component = props => (
const withSnackbar = (Component) => {
const WrappedComponent = props => (
<SnackbarContext.Consumer>
{handlePresentSnackbar => (
<SnackbarContextNext.Consumer>
{context => (
<WrappedComponent
<Component
{...props}
onPresentSnackbar={handlePresentSnackbar}
enqueueSnackbar={context.handleEnqueueSnackbar}
Expand All @@ -19,9 +19,9 @@ const withSnackbar = (WrappedComponent) => {
</SnackbarContext.Consumer>
);

Component.displayName = `withSnackbar(${WrappedComponent.displayName || WrappedComponent.name || 'Component'})`;
WrappedComponent.displayName = `withSnackbar(${Component.displayName || Component.name || 'Component'})`;

return Component;
return WrappedComponent;
};

export default withSnackbar;

0 comments on commit e88d073

Please sign in to comment.