// @flow import * as React from 'react' import App, { Container } from 'next/app' import Head from 'next/head' import Layout from '../components/layout' import { withCookies } from '../config/rpc' import { Provider } from 'react-redux' import ErrorP, { Overlay } from './_error' import styled from 'styled-components' import { withRedux } from '../config/redux' type NextPage = React.Component & React.StatelessFunctionalComponent & { getInitialProps: (ctx: any, ...args: any) => any } const MissingJS = styled.noscript` display: flex; justify-content: center; align-items: center; height: 100vh; width: 100vw; font-size: 1.3em; padding: 1em; ` class RoleypolyApp extends App { static async getInitialProps ({ Component, ctx, router }: { Component: NextPage, router: any, ctx: {[x:string]: any}}) { // Fix for next/error rendering instead of our error page. // Who knows why this would ever happen. if (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') { Component = ErrorP } // console.log({ Component }) let pageProps = {} const rpc = withCookies(ctx) const user = await rpc.getCurrentUser() ctx.user = user ctx.robots = 'INDEX, FOLLOW' ctx.layout = { noBackground: false } if (Component.getInitialProps) { pageProps = await Component.getInitialProps(ctx, rpc, router) } // console.log({ pageProps }) return { pageProps, user, layout: ctx.layout, robots: ctx.robots } } catchFOUC () { setTimeout(() => { if (document.documentElement) document.documentElement.className += ' force-active' }, 700) } componentDidMount () { this.catchFOUC() } render () { const { Component, pageProps, router, user, layout, robots, store } = this.props // Fix for next/error rendering instead of our error page. // Who knows why this would ever happen. const ErrorCaughtComponent = (Component.displayName === 'ErrorPage' || Component.constructor.name === 'ErrorPage') ? ErrorP : Component return Hey there... Unfortunately, we require JS for this app to work. Please take this rose as retribution. 🌹 Roleypoly