_:warning: Potential issue_
Add error handling for location fetching
The location fetching logic lacks error handling and loading state management.
+ const [isLoading, setIsLoading] = useState(false);
+ const [error, setError] = useState(null);
useEffect(() => {
+ const abortController = new AbortController();
+ setIsLoading(true);
httpService
- .getLocationsWithLatLon(userPosition.lat, userPosition.lng, categories)
+ .getLocationsWithLatLon(userPosition.lat, userPosition.lng, categories, abortController.signal)
.then(places => {
setData(places);
+ })
+ .catch(error => {
+ if (!error.name === 'AbortError') {
+ setError(error);
+ console.error('Failed to fetch locations:', error);
+ }
+ })
+ .finally(() => {
+ setIsLoading(false);
});
+ return () => abortController.abort();
}, [categories, userPosition]);
Committable suggestion skipped: line range outside the PR's diff.
🧰 Tools
🪛 eslint
[error] 28-28: Expected parentheses around arrow function argument.
(arrow-parens)
Originally posted by @coderabbitai[bot] in #90 (comment)
Add error handling for location fetching
The location fetching logic lacks error handling and loading state management.
🧰 Tools
🪛 eslint
[error] 28-28: Expected parentheses around arrow function argument.
(arrow-parens)
Originally posted by @coderabbitai[bot] in #90 (comment)