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

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

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

Merged
rwieruch merged 1 commit into the-road-to-learn-react:master from John-Spraul:master
May 24, 2019

Conversation

@John-Spraul
Copy link

@John-Spraul John-Spraul commented May 21, 2019
edited
Loading

Code 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```

Doing exactly as Matt Wright said yielded an error for me, so I changed it as much as I needed to.

PR for changes to blog post: rwieruch/blog_robinwieruch_content#107

rwieruch reacted with hooray emoji
code changes for issue #89 on blog_robinwieruch_content
Copy link
Member

Perfect!

@rwieruch rwieruch merged commit 52ee2d4 into the-road-to-learn-react:master May 24, 2019
rwieruch added a commit to rwieruch/blog_robinwieruch_content that referenced this pull request May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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