Skip to content

Instantly share code, notes, and snippets.

@tudorilisoi
Created September 4, 2020 18:37
Show Gist options
  • Save tudorilisoi/ab23c164208e03fde859cb994778799e to your computer and use it in GitHub Desktop.
Save tudorilisoi/ab23c164208e03fde859cb994778799e to your computer and use it in GitHub Desktop.
React layout wrapper HOC
export default function Layout(props) {
const classes = useStyles()
const gc = useGlobalStyles()
const { data: { user, loading } } = useContext(AppContext)
console.log(`LOADING ${loading}`)
const menuProps = { user }
return (
<>
<main className={classes.main}>
{/* {loading ? (<p>Loading...</p>) : props.children} */}
{props.children}
</main>
<footer>
Copyright {new Date().getFullYear()} &copy; me
</footer>
</>
)
}
//HOC
export const withLayout = (Component, cProps = {}) => {
const name = `withLayout-${C.displayName || C.name}`
function WithLayout(props) {
return (
<Layout {...props}>
<Component {...cProps} />
</Layout>
)
}
WithLayout.displayName = name
return WithLayout
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment