Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 52ee2d4

Browse files
Merge pull request #11 from John-Spraul/master
changes for react-hooks-fetch-data: cleaner API
2 parents c25d28e + ec2628e commit 52ee2d4

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

‎src/useDataApiHook-example/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,12 @@ const useDataApi = (initialUrl, initialData) => {
6363
};
6464
}, [url]);
6565

66-
const doFetch = url => {
67-
setUrl(url);
68-
};
69-
70-
return { ...state, doFetch };
66+
return [state, setUrl];
7167
};
7268

7369
function App() {
7470
const [query, setQuery] = useState('redux');
75-
const {data, isLoading, isError, doFetch} = useDataApi(
71+
const [{data, isLoading, isError}, doFetch] = useDataApi(
7672
'http://hn.algolia.com/api/v1/search?query=redux',
7773
{ hits: [] },
7874
);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /