fix(curriculum): update steps 15-16 in fruit search app workshop (#60906)

Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
This commit is contained in:
Vishnu D
2025-06-18 10:04:44 +05:30
committed by GitHub
parent 4f59955ea0
commit c43429a9b1
2 changed files with 6 additions and 6 deletions
@@ -9,7 +9,7 @@ dashedName: step-15
If `query` is not empty, you want to get fruits that match the user input from the API, but only after users stop typing for a short period to avoid making the fetch call too frequently.
To start, after the `if` statement, call `setTimeout` with a delay value of `700` and store it in a variable called `timeoutId`. This allows you to cancel the timeout later when the effect cleans up.
To start, after the `if` statement, call `setTimeout` with an empty arrow function and a delay value of `700` as arguments, and store it in a variable called `timeoutId`. This allows you to cancel the timeout later when the effect cleans up.
# --hints--
@@ -19,10 +19,10 @@ You should call `setTimeout` and store the return value in a variable called `ti
assert.match(code, /(const|let|var)\s+timeoutId\s*=\s*setTimeout\s*\(/s);
```
`setTimeout` should have a delay value of `700`.
`setTimeout` should have an empty callback function and a delay value of `700`.
```js
assert.match(code, /(const|let|var)\s+timeoutId\s*=\s*setTimeout\s*\(\s*700\s*\)/);
assert.match(code, /(const|let|var)\s+timeoutId\s*=\s*setTimeout\s*\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*,\s*700\s*\)/);
```
# --seed--
@@ -7,11 +7,11 @@ dashedName: step-16
# --description--
The first argument to `setTimeout`, before the delay value, should be an `async` arrow function, which allows you to use `await` inside the delayed logic. Inside that function, create a `try...catch` block to handle potential errors while fetching data.
Update the first argument to `setTimeout` to an `async` arrow function. This allows you to use `await` inside the delayed logic. Inside that function, create a `try...catch` block to handle any potential errors when fetching data.
# --hints--
You should use an `async` arrow function as the first argument to `setTimeout`.
You should have an `async` arrow function as the first argument to `setTimeout`.
```js
assert.match(code, /setTimeout\s*\(\s*async\s*\(\s*\)\s*=>\s*{/);
@@ -115,7 +115,7 @@ export function FruitsSearch() {
setResults([]);
return;
}
const timeoutId = setTimeout(700);
const timeoutId = setTimeout(() => {}, 700);
}, [query]);
--fcc-editable-region--