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