May 2019
Intermediate to advanced
496 pages
10h 38m
English
Previously, we had an onSubmit prop that we've removed in favor of calling window.fetch. Now let's add that prop back in! But this time, it will do something else: it will be used to notify its parent component when the form data has been saved successfully. So instead of onSubmit, let's call it onSave, just to show that it's doing something different.
When a new customer is saved, CustomerForm needs to return the new customer object. This will be the same data we submitted, but in addition, it will contain an ID that the server assigns to the customer.
To achieve this, we can ask our fetchSpy to return a value whenever it is called. This is known as a stub. ...
Read now
Unlock full access