May 2019
Intermediate to advanced
496 pages
10h 38m
English
You may be scratching your head wondering why we passed in fetch as a prop when it's available as a global variable. In the browser, we can simply call window.fetch when we need it.
That's where we'll eventually end up, but we've split that goal up into two subgoals. We started by taking the smallest step possible to move away from using onSubmit. Now let's take the next step to using window.fetch.
The easy way to do this would be to simply update your defaultProp to point to window.fetch, and that would be it. This is a perfectly valid approach, but it produces more production code than necessary due to the extra prop. Let's just get rid of the prop entirely.
We'll need to overwrite the value of window.fetch ...
Read now
Unlock full access