Make modal button work.

pull/226/head
Atul Varma 2021-09-23 15:38:15 -04:00
rodzic 4d4baca1c3
commit 160749762f
1 zmienionych plików z 6 dodań i 4 usunięć

Wyświetl plik

@ -86,15 +86,17 @@ export function createPageWithShareableState<T>({
/** The default state from the URL, which we'll pass into our component. */
let defaults: T = defaultValue;
let deserializeError = false;
let didDeserializeThrow = false;
try {
defaults = deserialize(state || "");
} catch (e) {
console.log(`Error deserializing state: ${e}`);
deserializeError = true;
didDeserializeThrow = true;
}
const [showError, setShowError] = useState(didDeserializeThrow);
const onChange = useCallback(
(value: T) => {
const newState = serialize(value);
@ -119,7 +121,7 @@ export function createPageWithShareableState<T>({
return (
<>
{deserializeError && (
{showError && (
<div className="page-error">
<div>
<p>
@ -130,7 +132,7 @@ export function createPageWithShareableState<T>({
Either its data is corrupted, or displaying it is no longer
supported.
</p>
<button>Alas</button>
<button onClick={() => setShowError(false)}>OK</button>
</div>
</div>
)}