Skip to content

Instantly share code, notes, and snippets.

View Undermaken's full-sized avatar
:octocat:
First, solve the problem. Then write the code

Matteo Boschi Undermaken

:octocat:
First, solve the problem. Then write the code
View GitHub Profile
@Undermaken
Undermaken / useNeedToRefresh.ts
Last active December 20, 2023 10:06
Hook to automatically refresh a single page app. This is particularly useful for those apps that don't use a remote versioning control and where users keep the app open for long periods
/**
* this hook is used to check if the app needs to be refreshed
* it stores the last time the page has been refreshed in local storage
* if it's been more than {@param minutes}, it returns true
* it is executed on window focus.
* this is particularly useful for those apps that don't use a remote versioning control
* and where users keep the app open for long periods
*/
import { useCallback, useEffect, useState } from "react";
{"lastUpload":"2020-05-18T12:09:30.631Z","extensionVersion":"v3.4.3"}