diff --git a/src/components/Playground.jsx b/src/components/Playground.jsx index 763e3c95..44929c21 100644 --- a/src/components/Playground.jsx +++ b/src/components/Playground.jsx @@ -254,9 +254,22 @@ export default function Playground() { }) } - const [getFetcherCallFlag, setGetFetcherCallFlag] = useState(false) - const { data: tutoData, error, isLoading } = useSWR('http://localhost:8080/api/tutorial', getFetcher) - const { trigger, isMutating } = useSWRMutation('http://localhost:8080/api/tutorial', postFetcher) + const [callFlag, setCallFlag] = useState(false) + // const { data: tutoData, error, isLoadin g } = useSWR('http://localhost:8080/api/tutorial', getFetcher) + const { data: tutoData, error, isLoading } = useSWR(callFlag ? 'http://localhost:8080/api/tutorial' : null, getFetcher) + const { trigger, isMutating: postIsMutating } = useSWRMutation('http://localhost:8080/api/tutorial', postFetcher) + + if (isLoading) { + return
Loading...
+ } + + if (error) { + return
Error...
+ } + + useEffect(() => { + trigger({ id: 3, name: 'seulda kim', email: 'seulda.kim@interplug.co.kr' }) + }, [tutoData]) return ( <> @@ -571,7 +584,12 @@ export default function Playground() { ))}
- + +
+
+