1.0.2 • Published 4 years ago

@lchooks/use-axios v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

@lchooks/use-axios

React Hook to request data asynchronous And Refetch when the user executing a function.

노마드코더 수업을 들으면서 클론코딩했습니다. Thank you nomadcoders!! https://academy.nomadcoders.co/p/introduction-to-react-hooks

Installation

yarn

yarn add @lchooks/use-axios

npm

npm i @lchooks/use-axios

Usage

import React from "react";
import useAxios from "@lchooks/use-axios";

function App() {
  const { loading, data, error, refetch } = useAxios({
    url: "https://yts.mx/api/v2/list_movies.json"
  });
  return (
    <div className="App">
      <h1>{data && data.status}</h1>
      <h2>{loading && "Loading"}</h2>
      <button onClick={refetch}>Refetch</button>
    </div>
  );
}

Arguments

ArgumentTypeDescriptionRequiredDefault value
optarrayArray to request using Axiosyesnull
axiosInstacneaxiosAxios for Asynchronous ProcessingnodefaultAxios

Return

Return valueTypeDescriptionDefault value
stateObjectAn object containing the response valuenull
refetchFunctionAn function to refetchnull
1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago