mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
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:
+3
-3
@@ -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--
|
||||
|
||||
+3
-3
@@ -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--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user