Disable stats loading on the client
This commit is contained in:
parent
957aec9a22
commit
ca3def5372
|
@ -1,6 +1,7 @@
|
||||||
/** @jsx jsx */
|
/** @jsx jsx */
|
||||||
import { Global, css, jsx } from '@emotion/core';
|
import { Global, css, jsx } from '@emotion/core';
|
||||||
import { Fragment, useEffect, useState } from 'react';
|
// import { Fragment, useEffect, useState } from 'react';
|
||||||
|
import { Fragment, useState } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import formatBytes from 'pretty-bytes';
|
import formatBytes from 'pretty-bytes';
|
||||||
import formatDate from 'date-fns/format';
|
import formatDate from 'date-fns/format';
|
||||||
|
@ -91,7 +92,8 @@ function Stats({ data }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const [stats, setStats] = useState(
|
// const [stats, setStats] = useState(
|
||||||
|
const [stats] = useState(
|
||||||
typeof window === 'object' &&
|
typeof window === 'object' &&
|
||||||
window.localStorage &&
|
window.localStorage &&
|
||||||
window.localStorage.savedStats
|
window.localStorage.savedStats
|
||||||
|
@ -99,17 +101,17 @@ export default function App() {
|
||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
const hasStats = !!(stats && !stats.error);
|
const hasStats = !!(stats && !stats.error);
|
||||||
const stringStats = JSON.stringify(stats);
|
// const stringStats = JSON.stringify(stats);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
window.localStorage.savedStats = stringStats;
|
// window.localStorage.savedStats = stringStats;
|
||||||
}, [stringStats]);
|
// }, [stringStats]);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
fetch('/api/stats?period=last-month')
|
// fetch('/api/stats?period=last-month')
|
||||||
.then(res => res.json())
|
// .then(res => res.json())
|
||||||
.then(setStats);
|
// .then(setStats);
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
|
|
Loading…
Reference in New Issue