Obfuscate environment variables

This commit is contained in:
Gregory Schier
2024-03-16 10:42:46 -07:00
parent 98493a1167
commit 33c982b288
5 changed files with 46 additions and 11 deletions

View File

@@ -0,0 +1,12 @@
import { useEffect, useState } from 'react';
/**
* Like useState, except it will update the value when the default value changes
*/
export function useStateSyncDefault<T>(defaultValue: T) {
const [value, setValue] = useState(defaultValue);
useEffect(() => {
setValue(defaultValue);
}, [defaultValue]);
return [value, setValue] as const;
}