soso-tip
soso-tip copied to clipboard
[WIP] react-query ์ ๋ฆฌ
[wip] isSuccess
๊ถ๊ธํ ์ : https://react-query.tanstack.com/docs/api ์์ onSuccess
์ฝ๋ฐฑ๋ ์๊ณ , isSuccess
๋์๋๋ฐ ๋ ๊ฐ์ ์ฐจ์ด๋ ํ์ด๋ฐ์? ๋จ์ํ DX?
์ด ๋ถ๋ถ์ ์ฝ๋๋ฅผ ๋ณด๋ ํ์ด๋ฐ์ onSuccess
์ฝ๋ฐฑ์ด ๋จผ์ ๋ถ๋ฆด๊ฒ ๊ฐ๋ค. ์ดํ์ isSuccess
๊ฐ์ด true๊ฐ ๋์ง ์์๊น.
post request
const [mustate, { isSucess, isLoading..} ] = useMutation<Response, ErrorResponse, ReqeustBody>(requestFn, config)
์ด๋ ๊ฒ ์ฐ๋ฉด๋จ.
Suspense
const queryCache = new QueryCache({
defaultConfig: {
queries: {
suspense: true,
},
},
});
ReactDOM.render(
<React.StrictMode>
<ReactQueryCacheProvider queryCache={ queryCache }>
<App />
<ReactQueryDevtools initialIsOpen />
</ReactQueryCacheProvider>
</React.StrictMode>,
document.getElementById('root'),
)