https://www.npmjs.com/package/axios-hooks
React hooks for axios, with built-in support for server side rendering.
서버 측 렌더링에 대한 지원이 내장 된 axios 용 React 후크.
특징
- All the axios awesomeness you are familiar with
- 친숙하다.- Zero configuration, but configurable if needed
- 무설정, 필요시 설정가능- One-line usage
- 한 줄 사용- Super straightforward to use with SSR
- SSR과 함께 사용하기 매우 간단
import useAxios from 'axios-hooks'
function App() {
const [{ data, loading, error }, refetch] = useAxios(
'https://reqres.in/api/users?delay=1'
)
if (loading) return <p>Loading...</p>
if (error) return <p>Error!</p>
return (
<div>
<button onClick={refetch}>refetch</button>
<pre>{JSON.stringify(data, null, 2)}</pre>
</div>
)
}