From 063ee77a7363478c9897c7239724389ef5887df4 Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Mon, 14 May 2018 12:01:48 -0400 Subject: routing --- frontend/pages/_app.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'frontend/pages/_app.js') diff --git a/frontend/pages/_app.js b/frontend/pages/_app.js index c741c4d..65a6fe3 100644 --- a/frontend/pages/_app.js +++ b/frontend/pages/_app.js @@ -7,29 +7,28 @@ import { withRouter } from 'next/router'; // This code is taken right from the Next.js docs, and then we add the Router to the page props, which is why we need a custom _app.js -let ComposedComponent; - class MyApp extends App { - static async getInitialProps({ Component, router, ctx }) { + static async getInitialProps({ Component, ctx }) { + console.log('GET INITITAL PROPS'); let pageProps = {}; - ComposedComponent = withData(Component); + const ComposedComponent = withData(Component); if (ComposedComponent.getInitialProps) { - pageProps = await ComposedComponent.getInitialProps(ctx); + pageProps = await withData(Component).getInitialProps(ctx); } - pageProps.router = router; - return { pageProps }; + return { pageProps, query: ctx.query }; } render() { - const { Component, pageProps } = this.props; - + console.log('RENDER'); + const { Component, pageProps, query } = this.props; + const ComposedComponent = withData(Component); return ( - + ); } } -export default withData(MyApp); +export default MyApp; -- cgit v1.3