Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide displayName to withSnackbar HOC #99

Closed
Lukas-Kullmann opened this issue Mar 25, 2019 · 0 comments · Fixed by #100
Closed

Provide displayName to withSnackbar HOC #99

Lukas-Kullmann opened this issue Mar 25, 2019 · 0 comments · Fixed by #100

Comments

@Lukas-Kullmann
Copy link
Contributor

The current implementation of the withSnackbar HOC does not provide a displayName. For testing purposes (e.g. Snapshot tests), it would be great if it would provide one.

Example implementation:

const withSnackbar = Component => {
    const WrappedComponent = props => (
        <SnackbarContext.Consumer>
            {handlePresentSnackbar => (
                <SnackbarContextNext.Consumer>
                    {context => (
                        <Component
                            {...props}
                            onPresentSnackbar={handlePresentSnackbar}
                            enqueueSnackbar={context.handleEnqueueSnackbar}
                            closeSnackbar={context.handleCloseSnackbar}
                        />
                    )}
                </SnackbarContextNext.Consumer>
            )}
        </SnackbarContext.Consumer>
    }

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

    return WrappedComponent;
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant