Skip to content

Instantly share code, notes, and snippets.

@ryanbelke
Created October 13, 2018 18:17
Show Gist options
  • Select an option

  • Save ryanbelke/7a2343d578014a918d55e45e7a33ae2d to your computer and use it in GitHub Desktop.

Select an option

Save ryanbelke/7a2343d578014a918d55e45e7a33ae2d to your computer and use it in GitHub Desktop.
_app.js updated with React Context
/* /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