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

refactor: useSidebarSearch.ts to ⚒️✨ #1454

Closed
wants to merge 1 commit into from
Closed

refactor: useSidebarSearch.ts to ⚒️✨ #1454

wants to merge 1 commit into from

Conversation

0xabdulkhaliq
Copy link
Contributor

Fixes Issue

Close #1450

Changes proposed

  • The refactoring of the useSidebarSearch TypeScript script includes the following changes, which lead to improvements in code organization, maintainability, and type safety.

Outcome

  1. Modularity: The refactoring introduces modularity by splitting the filtering and mapping logic into separate functions. This enhances code organization, making it easier to understand and maintain. The main useSidebarSearch function focuses solely on handling state and side effects.

  2. Descriptive Variable Names: Variable names are updated to be more descriptive, enhancing code readability. Clear and meaningful variable names make it easier for other developers to understand the purpose of each variable.

  3. Type Annotations: TypeScript interfaces are used to provide type safety for the data structures used in the script. Specifically, the SidebarItem interface ensures that the searchResults state and other data structures adhere to the correct structure, avoiding potential type-related errors.

  4. Destructuring: Destructuring is used to simplify the code and avoid repetitive object property access. This reduces verbosity and improves the overall readability of the script.

  5. Error Handling: The script now includes error handling for the API fetch request. If the response from the API is not successful, it throws an error, which provides a clear indication of network issues. The error handling logic can be further extended to handle other types of errors if necessary.

  6. These improvements in code organization, variable naming, type safety, and error handling enhance the overall quality of the useSidebarSearch script. The refactored code becomes more maintainable, extensible, and less prone to errors. Additionally, the use of TypeScript interfaces ensures that data structures are well-defined and consistent, contributing to a more robust and reliable implementation.

@vercel
Copy link

vercel bot commented Jul 31, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
linkshub ❌ Failed (Inspect) Jul 31, 2023 4:17pm

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, 0xabdulkhalid, for creating this pull request and contributing to LinksHub! 💗

The maintainers will review this Pull Request and provide feedback as soon as possible! 😇
We appreciate your patience and contribution, Keep up the great work! 😀

@0xabdulkhaliq
Copy link
Contributor Author

📌 I will resolve the vercel deploying error within tomorrow evening

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

Successfully merging this pull request may close these issues.

[Refactor]: search bar typescript code with best practices 🪄✨
1 participant