Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes for react-hooks-fetch-data: cleaner API #107

Closed
wants to merge 1 commit into from

Conversation

John-Spraul
Copy link

Blog post changes for issue #89 on blog_robinwieruch_content.

Based on this comment by Matt Wright:

You can make your fetch hook cleaner by removing

const doFetch = url => {
setUrl(url);
};

and just returning setUrl like so

return [ ...state, setUrl ];

then change your hook call to

const [ data, doFetch ] = useDataApi(
'http://hn.algolia.com/api/v1/search?query=redux',
{ hits: [] },
);

And now you can rename "doFetch" to anything you want```

PR for changes in example code: the-road-to-learn-react/react-hooks-introduction#11

blog post changes for issue rwieruch#89 on blog_robinwieruch_content
@rwieruch
Copy link
Owner

rwieruch commented May 24, 2019

There were a few more code snippets to adjust, that's why I just committed the changes myself (see 6ec4f50). Thank you though! Hope I spotted every thing that needed to be changed :)

@rwieruch rwieruch closed this May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants