-
-
Save AlanGreene/2b31d44cc2bc75d62669cc7e6c7d1db9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If the user has been on the page for over 12 hours, the next link | |
// click will do a full page transition to get new code | |
import React from "react"; | |
import { BrowserRouter, useLocation } from "react-router-dom"; | |
let hour = 3600000; | |
export default function StaleAppRouter(props) { | |
let [isStale, setIsStale] = useState(false); | |
useEffect(() => { | |
let id = setTimeout(() => { | |
setIsStale(true) | |
}, hour * 12) | |
return () => clearTimeout(id) | |
}, []); | |
return <BrowserRouter forceRefresh={isStale} /> | |
} | |
// now replace your <BrowserRouter /> with a <StaleAppRouter /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment