Skip to content

Commit 52ee2d4

Browse files
authored
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)