Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors #11

Open
cjcenizal opened this issue Jan 17, 2024 · 0 comments
Open

Handle errors #11

cjcenizal opened this issue Jan 17, 2024 · 0 comments
Assignees

Comments

@cjcenizal
Copy link
Contributor

cjcenizal commented Jan 17, 2024

The component needs to handle errors and surface them to the user. Looks like right now the code doesn't anticipate them:

const sendSearchQuery = async (query: string) => {
if (query.length === 0) {
return;
}
if (isDeeplinkable) {
// Persist search.
const queryParams = new URLSearchParams(window.location.search);
queryParams.set("search", query);
history.replaceState(null, "", "?" + queryParams.toString());
}
addPreviousSearch(query);
const searchId = ++searchCount.current;
const results = await fetchSearchResults(query);
if (searchId === searchCount.current) {
setSearchResults(results);
setSelectedResultIndex(null);
selectedResultRef.current = null;
}
};

@cjcenizal cjcenizal self-assigned this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant