Polished and fixed Edit note page not displaying properly while loading

This commit is contained in:
keannu125 2023-03-25 12:31:43 +08:00
parent eff9ebcbfa
commit 33ea3f8080

View file

@ -3,9 +3,8 @@ import { Button } from "@mui/material";
import { useNavigate, useParams } from "react-router-dom"; import { useNavigate, useParams } from "react-router-dom";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import Header from "../../Components/Header/Header"; import Header from "../../Components/Header/Header";
import { AddNote, GetNote, UpdateNote } from "../../Components/Api/Api"; import { GetNote, UpdateNote } from "../../Components/Api/Api";
import { useMutation, useQuery, useQueryClient } from "react-query"; import { useMutation, useQuery, useQueryClient } from "react-query";
import { NoteProps } from "../../Interfaces/Interfaces";
export interface input { export interface input {
e: React.ChangeEvent; e: React.ChangeEvent;
@ -34,7 +33,7 @@ export default function ViewNote() {
}); });
useEffect(() => { useEffect(() => {
setNote(data); setNote(data);
}, []); }, [data]);
if (error) { if (error) {
return ( return (
<div style={styles.background}> <div style={styles.background}>
@ -47,8 +46,10 @@ export default function ViewNote() {
} }
if (isLoading) { if (isLoading) {
return ( return (
<div style={styles.note}> <div style={styles.background}>
<p style={styles.text_medium}>Loading Note...</p> <div style={styles.note}>
<p style={styles.text_medium}>Loading Note...</p>
</div>
</div> </div>
); );
} }
@ -112,4 +113,4 @@ export default function ViewNote() {
); );
} }
return <div>heh</div>; return <div>heh</div>;
} }