Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/AppContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NextDocumentContext } from "next/document"
import { Store } from "redux"

/**
* NextDocumentContext with redux store context
* @tree
*/
export type AppContext = NextDocumentContext & {
readonly store: Store
}
15 changes: 8 additions & 7 deletions pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ServerStyleSheets } from "@material-ui/styles"
import Document, { Head, Main, NextScript } from "next/document"
import React from "react"
import flush from "styled-jsx/server"
import { MuiTheme } from "../components/MuiTheme"
import "../styles/main.css"
import { ServerStyleSheets } from "@material-ui/styles";
import Document, { Head, Main, NextScript } from "next/document";
import React from "react";
import flush from "styled-jsx/server";
import { AppContext } from "../components/AppContext";
import { MuiTheme } from "../components/MuiTheme";
import "../styles/main.css";

interface IProps {
pageProps: any
Expand All @@ -13,7 +14,7 @@ interface IProps {
* @see https://github.com/mui-org/material-ui/blob/master/examples/nextjs-with-typescript/pages/_document.tsx
*/
class MyDocument extends Document<IProps> {
static getInitialProps = async ctx => {
static getInitialProps = async (ctx: AppContext) => {
// Render app and page and get the context of the page with collected side effects.
const sheets = new ServerStyleSheets()

Expand Down
3 changes: 2 additions & 1 deletion pages/about.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Typography } from "@material-ui/core"
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import React from "react"
import { AppContext } from "../components/AppContext"
import { SpacingPaper } from "../components/atoms"
import { HeaderArticleContainer } from "../components/organisms"
import { Layout } from "../components/templates"
Expand Down Expand Up @@ -29,7 +30,7 @@ function About() {
/**
* Server side rendering
*/
About.getInitialProps = async ctx => {
About.getInitialProps = async (ctx: AppContext) => {
const pagePayload: IPagePayload = {
selectedPage: Page.ABOUT,
}
Expand Down
3 changes: 2 additions & 1 deletion pages/redux.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"
import React, { useState } from "react"
import { useDispatch, useSelector } from "react-redux"
import { AppContext } from "../components/AppContext"
import { SpacingPaper } from "../components/atoms"
import { HeaderArticleContainer } from "../components/organisms"
import { Layout } from "../components/templates"
Expand Down Expand Up @@ -121,7 +122,7 @@ function Redux() {
/**
* Server side rendering
*/
Redux.getInitialProps = async ctx => {
Redux.getInitialProps = async (ctx: AppContext) => {
const pagePayload: IPagePayload = {
selectedPage: Page.REDUX,
}
Expand Down