Skip to content

Instantly share code, notes, and snippets.

@juanmaguitar
Last active June 3, 2018 11:05
Show Gist options
  • Save juanmaguitar/543b240c74546a8230540887e47acc27 to your computer and use it in GitHub Desktop.
Save juanmaguitar/543b240c74546a8230540887e47acc27 to your computer and use it in GitHub Desktop.
import React from "react";
import { compose, setDisplayName } from "recompose";
const withDisplayMessages = WrappedComponent => props => {
const { children, messages, loading, ..._props } = props;
return (
<WrappedComponent {..._props}>
{children}
{loading ? (
<span className="fas fa-spinner fa-pulse"> </span>
) : (
<span className="badge badge-light">{messages}</span>
)}
</WrappedComponent>
);
};
export default compose(
setDisplayName("withDisplayMessages"),
withDisplayMessages
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment