This file contains hidden or 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
async function downloadTextAsFile(text: string, filename: string): Promise<void> { | |
if (!filename.endsWith(".txt")) { | |
filename = `${filename}.txt`; | |
} | |
const blob = new Blob([text], { type: "text/plain" }); | |
const href = await URL.createObjectURL(blob); | |
const link = document.createElement("a"); | |
link.href = href; | |
link.download = filename; | |
link.style.position = "absolute"; |
This file contains hidden or 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
async function downloadObjectAsJSONFile(object: any, filename: string): Promise<void> { | |
if(!filename.endsWith('.json')) { | |
filename = `${filename}.json` | |
} | |
const json = JSON.stringify(object) | |
const blob = new Blob([json],{ type:'application/json' }) | |
const href = await URL.createObjectURL(blob) | |
const link = document.createElement('a') | |
link.href = href | |
link.download = filename |
This file contains hidden or 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
// The best way to split up your npm deps into smaller chunks | |
module.exports = (env) => { | |
const config = { | |
// ... rest of config options | |
optimization: { | |
runtimeChunk: "single", | |
splitChunks: { | |
cacheGroups: { | |
vendors: { |
This file contains hidden or 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
import { useEffect } from "react"; | |
/** | |
* A hook that prevents closing or refreshing if there are unsaved changes, | |
* offering the user a prompt to confirm before closing the window. | |
* @param promptBeforeClosingWindow A boolean indicating if we should prompt before closing | |
*/ | |
export function useBeforeClosingWindowPrompt(promptBeforeClosingWindow: boolean) { | |
useEffect((): (() => void) => { | |
function handleBeforeUnload(e: BeforeUnloadEvent): void { |
OlderNewer