Created
September 4, 2020 18:37
-
-
Save tudorilisoi/ab23c164208e03fde859cb994778799e to your computer and use it in GitHub Desktop.
React layout wrapper HOC
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
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()} © 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