fixing _document.tsx
This commit is contained in:
parent
df902d6306
commit
f9237cb7f8
9
.babelrc
9
.babelrc
@ -3,13 +3,6 @@
|
|||||||
"next/babel"
|
"next/babel"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
["styled-components", { "ssr": true }]
|
||||||
"styled-components",
|
|
||||||
{
|
|
||||||
"ssr": true,
|
|
||||||
"displayName": true,
|
|
||||||
"preprocess": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,21 +5,31 @@ import { ServerStyleSheet } from 'styled-components';
|
|||||||
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
import Document, { Html, Head, Main, NextScript } from 'next/document'
|
||||||
|
|
||||||
export default class MyDocument extends Document {
|
export default class MyDocument extends Document {
|
||||||
// static getInitialProps({ renderPage }) {
|
static async GetInitialProps(ctx) {
|
||||||
// // Step 1: Create an instance of ServerStyleSheet
|
const sheet = new ServerStyleSheet();
|
||||||
// const sheet = new ServerStyleSheet();
|
const originalRenderPage = ctx.renderPage;
|
||||||
|
|
||||||
// // Step 2: Retrieve styles from components in the page
|
try {
|
||||||
// const page = renderPage((App) => (props) =>
|
ctx.renderPage = () =>
|
||||||
// sheet.collectStyles(<App {...props} />),
|
originalRenderPage({
|
||||||
// );
|
enhanceApp: App => props => sheet.collectStyles(<App {...props} />)
|
||||||
|
});
|
||||||
|
|
||||||
// // Step 3: Extract the styles as <style> tags
|
const initialProps = await Document.getInitialProps(ctx);
|
||||||
// const styleTags = sheet.getStyleElement();
|
return {
|
||||||
|
...initialProps,
|
||||||
|
styles: (
|
||||||
|
<>
|
||||||
|
{initialProps.styles}
|
||||||
|
{sheet.getStyleElement()}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
} finally {
|
||||||
|
sheet.seal();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// // Step 4: Pass styleTags as a prop
|
|
||||||
// return { ...page, styleTags };
|
|
||||||
// }
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
// import { DashboardView } from '../styles/layouts/dashboard/DashboardView'
|
import { DashboardView } from '../styles/layouts/dashboard/DashboardView'
|
||||||
|
|
||||||
import MapCard from '../src/components/mapCard/MapCard'
|
import MapCard from '../src/components/mapCard/MapCard'
|
||||||
import GraphCard from '../src/components/graph/graphCard/ChartCard'
|
import GraphCard from '../src/components/graph/graphCard/ChartCard'
|
||||||
@ -9,7 +9,7 @@ import PageTitle from '../src/components/pageTitle/PageTitle'
|
|||||||
|
|
||||||
export default function Dashboard() {
|
export default function Dashboard() {
|
||||||
return (
|
return (
|
||||||
<main>
|
<DashboardView>
|
||||||
<Header name='' />
|
<Header name='' />
|
||||||
<PageTitle title='Visão Geral' subtitle='Bem Vindo a Smart Energia' />
|
<PageTitle title='Visão Geral' subtitle='Bem Vindo a Smart Energia' />
|
||||||
<section className="cardsSection" >
|
<section className="cardsSection" >
|
||||||
@ -25,6 +25,6 @@ export default function Dashboard() {
|
|||||||
<GraphCard title='Consumo' subtitle='Gráfico de Consumo' />
|
<GraphCard title='Consumo' subtitle='Gráfico de Consumo' />
|
||||||
<GraphCard title='Consumo' subtitle='Gráfico de Consumo' className='footerGraph' />
|
<GraphCard title='Consumo' subtitle='Gráfico de Consumo' className='footerGraph' />
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</DashboardView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user