Last active
June 3, 2018 11:05
-
-
Save juanmaguitar/543b240c74546a8230540887e47acc27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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