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: removed unnecessary state use for hover effect #3419

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions pages/community/tsc.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { sortBy } from 'lodash';
import React, { useState } from 'react';

import type { Tsc } from '@/types/pages/community/Community';

Expand Down Expand Up @@ -66,11 +65,9 @@ function addAdditionalUserInfo(user: Tsc) {
* @returns The Twitter SVG component.
*/
function TwitterSVG() {
const [isHovered, setIsHovered] = useState(false);

return (
<div className='size-5' onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
<IconTwitter className={isHovered ? 'hover:fill-black' : ''} />
<div className='size-5'>
<IconTwitter className='hover:fill-black' />
</div>
);
}
Expand All @@ -81,11 +78,9 @@ function TwitterSVG() {
* @returns The GitHub SVG component.
*/
function GitHubSVG() {
const [isHovered, setIsHovered] = useState(false);

return (
<div className='size-5' onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
<IconGithub className={isHovered ? 'hover:fill-black' : ''} />
<div className='size-5'>
<IconGithub className='hover:fill-black' />
</div>
);
}
Expand All @@ -96,12 +91,9 @@ function GitHubSVG() {
* @returns The LinkedIn SVG component.
*/
function LinkedInSVG() {
const [isHovered, setIsHovered] = useState(false);

return (
<div className='size-5' onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)}>
{/* Use the imported SVG icon component */}
<IconLinkedIn className={isHovered ? 'hover:fill-linkedin' : ''} />
<div className='size-5'>
<IconLinkedIn className='hover:fill-linkedin' />
</div>
);
}
Expand Down
Loading