From 27be35e9cac9ab87a88dd2f7507f87d08bc1be3e Mon Sep 17 00:00:00 2001 From: LUKASZ-JK <115374593+LUKASZ-JK@users.noreply.github.com> Date: Wed, 14 Aug 2024 21:21:04 +0200 Subject: [PATCH] Update onSubmit return type Frontend patientor repo linked in exercise 9.8 has return type of void, not Promise. We do not actually return anything from the submitNewPatient function, it is only used to set state (patients or error). If my line of thinking is wrong and material is correct then I think the patientor repo should be updated to reflect the material. --- src/content/9/en/part9e.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/content/9/en/part9e.md b/src/content/9/en/part9e.md index dd612f96434..462bbea39e2 100644 --- a/src/content/9/en/part9e.md +++ b/src/content/9/en/part9e.md @@ -128,7 +128,7 @@ Types look like the following: interface Props { modalOpen: boolean; onClose: () => void; - onSubmit: (values: PatientFormValues) => Promise; + onSubmit: (values: PatientFormValues) => void; error?: string; } @@ -143,13 +143,13 @@ const AddPatientModal = ({ modalOpen, onClose, onSubmit, error }: Props) => { () => void ``` -The type of *onSubmit* is a bit more interesting, it has one parameter that has the type *PatientFormValues*. The return value of the function is _Promise<void>_. So again the function type is written with the arrow syntax: +The type of *onSubmit* is a bit more interesting, it has one parameter that has the type *PatientFormValues*. The return value of the function is _<void>_. So again the function type is written with the arrow syntax: ```js -(values: PatientFormValues) => Promise +(values: PatientFormValues) => ``` -The return value of a *async* function is a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function#return_value) with the value that the function returns. Our function does not return anything so the proper return type is just _Promise<void>_. +The return value of a *async* function is a [promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function#return_value) with the value that the function returns. Our function does not return anything so the proper return type is just _<void>_.