Skip to content

Instantly share code, notes, and snippets.

View Irrelon's full-sized avatar

Rob Evans Irrelon

View GitHub Profile
@Irrelon
Irrelon / getPageContext.js
Created April 15, 2019 09:50
./hoc/getPageContext.js for material-ui support in next.js
import {SheetsRegistry} from 'jss';
import {createGenerateClassName} from '@material-ui/core/styles';
import { createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
typography: {
useNextVariants: true
}
});
@Irrelon
Irrelon / _document.js
Created April 15, 2019 09:49
./pages/_document.js for material-ui next.js apps
/*
Remember that _document is a SERVER-ONLY page. It will never execute on the client.
*/
import React from "react";
import Document, {Head, Main, NextScript} from "next/document";
import JssProvider from "react-jss/lib/JssProvider";
import flush from "styled-jsx/server";
import getPageContext from "../hoc/getPageContext";
const withJssProvider = (Component, pageContext, props) => (
var arr = ["2016-12-09", "2016-12-09", "2016-12-09", "2016-12-09", "2016-12-10"],
bucket = {},
data = [],
i;
for (i = 0; i < arr.length; i++) {
if (bucket[arr[i]]) {
bucket[arr[i]]++;
} else {
bucket[arr[i]] = 1;