Replies: 7 comments
-
data fetching라이브러리는 위와같은 리덕스의 단점을 해결
|
Beta Was this translation helpful? Give feedback.
-
SWR
import useSWR from "swr";
function Profile() {
const { data, error } = useSWR("/api/user", fetcher, options);
if (error) return <div>failed to load</div>;
if (!data) return <div>loading...</div>;
return <div>hello {data.name}!</div>;
}
|
Beta Was this translation helpful? Give feedback.
-
React Queryimport { useQuery } from "react-query";
const useUser = id => {
const result = useQuery(`/user/${id}`, fetcher, options);
return result;
};
function Example() {
const { isLoading, error, data } = useUser("123");
if (isLoading) return "Loading...";
if (error) return "An error has occurred: " + error.message;
return <div>hello {data.name}!</div>;
}
|
Beta Was this translation helpful? Give feedback.
-
RTK Query
|
Beta Was this translation helpful? Give feedback.
-
Redux Saga
|
Beta Was this translation helpful? Give feedback.
-
Redux Thunk
MiddleWare: dispatch 함수를 결합해서 새 dispatch 함수를 반환하는 고차함수
|
Beta Was this translation helpful? Give feedback.
-
결론
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions