Skip to content

Conversation

@John-Spraul
Copy link

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

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

code changes for issue #89 on blog_robinwieruch_content
@rwieruch
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

Labels

None yet

3 participants