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

Optimize the code for better speed #246

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lawrencemillard
Copy link

Optimize the code for better speed.

  • CategoryList Component: Replace useEffect with useMemo to memoize fetched categories, reducing unnecessary re-renders.
  • useKeyboardNavigation Hook: Replace switch statement with a more optimized approach using a record of actions for handling keyboard events.
  • useEscapeKey Hook: Use a single event listener for better performance.
  • useSnippets Hook: Cache fetched data using useMemo to improve performance.
  • CodePreview Component: Replace useEffect with a more efficient method for handling theme changes using a mutation observer.

Optimize the code for better speed.

* **CategoryList Component**: Replace `useEffect` with `useMemo` to memoize fetched categories, reducing unnecessary re-renders.
* **useKeyboardNavigation Hook**: Replace switch statement with a more optimized approach using a record of actions for handling keyboard events.
* **useEscapeKey Hook**: Use a single event listener for better performance.
* **useSnippets Hook**: Cache fetched data using `useMemo` to improve performance.
* **CodePreview Component**: Replace `useEffect` with a more efficient method for handling theme changes using a mutation observer.
@dostonnabotov
Copy link
Owner

Hey, there. Thanks for the optimizations. We will be able to merge the PR once the search functionality is implemented on #159. Because it's a pretty big PR with a lot of changes.

@Mathys-Gasnier
Copy link
Collaborator

Please resolve conflicts and we will be able to review

@dostonnabotov
Copy link
Owner

Hey there, @lawrencemillard.

Search functionality (#159) is successfully implemented. Feel free to resolve the conflicts and we should be good to go.

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.

3 participants