Make modal button work.
rodzic
4d4baca1c3
commit
160749762f
|
@ -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>
|
||||||
)}
|
)}
|
||||||
|
|
Ładowanie…
Reference in New Issue