Skip to content

Commit

Permalink
chore: change useMemo to useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
OXeu committed Jul 11, 2024
1 parent 361a8ea commit 200631c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions client/src/components/feed_card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function FeedCard({ id, title, avatar, draft, listed, top, summary, hasht
createdAt: Date, updatedAt: Date
}) {
const { t } = useTranslation()
const UI = useMemo(() => (
return useMemo(() => (
<>
<Link href={`/feed/${id}`} target="_blank" className="w-full rounded-2xl bg-w my-2 p-6 duration-300 ani-show bg-button">
{avatar &&
Expand Down Expand Up @@ -54,5 +54,4 @@ export function FeedCard({ id, title, avatar, draft, listed, top, summary, hasht
</Link>
</>
), [id, title, avatar, draft, listed, top, summary, hashtags, createdAt, updatedAt])
return UI
}
5 changes: 2 additions & 3 deletions client/src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function Header({ children }: { children?: React.ReactNode }) {
const profile = useContext(ProfileContext);
const { t } = useTranslation()

const UI = useMemo(() => (
return useMemo(() => (
<>
<div className="fixed z-40">
<div className="w-screen">
Expand Down Expand Up @@ -68,7 +68,6 @@ export function Header({ children }: { children?: React.ReactNode }) {
<div className="h-20"></div>
</>
), [profile, children])
return UI
}

function NavItem({ menu, title, selected, href, when = true, onClick }: {
Expand Down Expand Up @@ -272,7 +271,7 @@ function UserAvatar({ className, profile, onClose }: { className?: string, profi
<i className="ri-user-received-line"></i>
</button>
</>}
{LoginModal}
<LoginModal />
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useLoginModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { t } from "i18next";
import { Button } from "primereact/button";
import { useCallback, useMemo, useState } from "react";
import { useCallback, useState } from "react";
import ReactModal from "react-modal";
import { Icon } from "../components/icon";
import { Input } from "../components/input";
Expand All @@ -16,7 +16,7 @@ export function useLoginModal(onClose?: () => void) {
onClose?.()
}, 100)
}, [username, password])
const LoginModal = useMemo(() => {
const LoginModal = useCallback(() => {
return (
<ReactModal
isOpen={isOpened}
Expand Down
2 changes: 1 addition & 1 deletion client/src/page/feed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ function CommentInput({
)}
{error && <p className="text-red-500 text-sm mt-2">{error}</p>}
<AlertUI />
{LoginModal}
<LoginModal />
</div>
);
}
Expand Down

0 comments on commit 200631c

Please sign in to comment.