Created
October 13, 2018 18:17
-
-
Save ryanbelke/7a2343d578014a918d55e45e7a33ae2d to your computer and use it in GitHub Desktop.
_app.js updated with React Context
This file contains hidden or 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
| /* /pages/_app.js */ | |
| import Layout from "../components/Layout"; | |
| import withData from "../lib/apollo"; | |
| import AppProvider from "../components/Context/AppProvider"; | |
| import defaultPage from "../hocs/defaultPage"; | |
| import { compose } from "recompose"; | |
| import App, { Container } from "next/app"; | |
| import React from "react"; | |
| class MyApp extends App { | |
| static async getInitialProps({ Component, router, ctx }) { | |
| let pageProps = {}; | |
| if (Component.getInitialProps) { | |
| pageProps = await Component.getInitialProps(ctx); | |
| } | |
| return { pageProps }; | |
| } | |
| render() { | |
| const { Component, pageProps, isAuthenticated, ctx } = this.props; | |
| return ( | |
| <Container> | |
| <AppProvider> | |
| <Layout isAuthenticated={isAuthenticated} {...pageProps}> | |
| <Component {...pageProps} /> | |
| </Layout> | |
| </AppProvider> | |
| <style jsx global> | |
| {` | |
| a { | |
| color: white !important; | |
| } | |
| a:link { | |
| text-decoration: none !important; | |
| color: white !important; | |
| } | |
| a:hover { | |
| color: white; | |
| } | |
| .card { | |
| display: inline-block !important; | |
| } | |
| .card-columns { | |
| column-count: 3; | |
| } | |
| `} | |
| </style> | |
| </Container> | |
| ); | |
| } | |
| } | |
| export default withData(MyApp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment