プロジェクト
GitHubで見る
the-road-to-learn-react/use-data-api
概要
ReactコンポーネントからAPIのデータを取得するカスタムフック。
Web・アプリ開発計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルuseDataApi React Hook
Custom hook for React Components to fetch data from an API. Read more about it..
Installation
npm install use-data-api
Usage
Accepts as first argument an endpoint URL and as second argument an initial state for data. It returns as first item in an array an object which holds the data, isLoading and isError states, and the actual function to fetch the data (e.g. on a button click).
import React from 'react';
import useDataApi from 'use-data-api';
const AnyComponent = props => {
const [{ data, isLoading, isError }, doFetch] = useDataApi(
'http://hn.algolia.com/api/v1/search?query=redux',
null,
);
...
};
Contribute
git clone [email protected]:the-road-to-learn-react/use-data-api.gitcd use-data-apinpm installnpm run test
More
関連プロジェクトを探す
読み込み中…