diff --git a/packages/frontend/src/content/SaveNoteButton.tsx b/packages/frontend/src/content/SaveNoteButton.tsx
index 174cc22..be59059 100644
--- a/packages/frontend/src/content/SaveNoteButton.tsx
+++ b/packages/frontend/src/content/SaveNoteButton.tsx
@@ -1,40 +1,38 @@
-import React, { useState } from "react";
+import React, { useState, useTransition } from "react";
import { Button, Alert } from "react-bootstrap";
import { GATEWAY_URL } from "../config";
import { navigate } from "@reach/router";
import { ButtonSpinner } from "../components";
const SaveNoteButton = (props: { noteId: string; noteContent: string }) => {
- const [isSaving, setIsSaving] = useState(false);
+ const [isPending, startTransition] = useTransition();
const [errorMsg, setErrorMsg] = useState("");
const handleSave = async (event: any) => {
event.preventDefault();
- setIsSaving(true);
+ startTransition(async () => {
+ const { noteId, noteContent } = props;
+ const updateNoteURL = `${GATEWAY_URL}notes/${noteId}`;
- const { noteId, noteContent } = props;
- const updateNoteURL = `${GATEWAY_URL}notes/${noteId}`;
-
- try {
- await fetch(updateNoteURL, {
- method: "PUT",
- body: JSON.stringify({ content: noteContent }),
- });
- navigate("/");
- } catch (error) {
- console.log(error);
- setErrorMsg(`${error.toString()} - ${updateNoteURL} - ${noteContent}`);
- } finally {
- setIsSaving(false);
- }
+ try {
+ await fetch(updateNoteURL, {
+ method: "PUT",
+ body: JSON.stringify({ content: noteContent }),
+ });
+ navigate("/");
+ } catch (error) {
+ console.log(error);
+ setErrorMsg(`${error.toString()} - ${updateNoteURL} - ${noteContent}`);
+ }
+ });
};
return (
<>
{errorMsg &&
{errorMsg}}
-