diff --git a/webclient/src/Home.js b/webclient/src/Home.js index 98bcce7..1c580e0 100644 --- a/webclient/src/Home.js +++ b/webclient/src/Home.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useReducer } from 'react'; import { BrowserRouter as Router, Switch, Route, Link, useParams } from 'react-router-dom'; import moment from 'moment-timezone'; import './light.css'; @@ -130,6 +130,7 @@ function MemberInfo(props) { export function Home(props) { const { user } = props; const [stats, setStats] = useState(JSON.parse(localStorage.getItem('stats', 'false'))); + const [refreshCount, refreshStats] = useReducer(x => x + 1, 0); useEffect(() => { requester('/stats/', 'GET') @@ -141,7 +142,7 @@ export function Home(props) { console.log(err); setStats(false); }); - }, []); + }, [refreshCount]); const getStat = (x) => stats && stats[x] ? stats[x] : '?'; const getDateStat = (x) => stats && stats[x] ? moment.utc(stats[x]).tz('America/Edmonton').format('ll') : '?'; @@ -186,7 +187,7 @@ export function Home(props) {
{!!user && } - + refreshStats()} />