From e13d21da352bf8f1c2f92229441ab9e168b4cfdf Mon Sep 17 00:00:00 2001 From: Mark Linn Date: Thu, 7 Sep 2023 19:08:49 +0200 Subject: [PATCH] refactor: rm use of useHooks for native DaisyUI btn --- package.json | 1 - src/components/navbar/DropDown.tsx | 37 +++++++------------------- src/components/navbar/DropDownLink.tsx | 17 ++++++------ src/components/navbar/Navbar.tsx | 4 +-- yarn.lock | 5 ---- 5 files changed, 20 insertions(+), 44 deletions(-) diff --git a/package.json b/package.json index 358a34a2..e0b3948d 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,6 @@ "react": "18.2.0", "react-dom": "18.2.0", "react-redux": "^8.1.2", - "usehooks-ts": "^2.9.1", "zod": "^3.21.4" }, "devDependencies": { diff --git a/src/components/navbar/DropDown.tsx b/src/components/navbar/DropDown.tsx index 5a2d7403..f164ecf1 100644 --- a/src/components/navbar/DropDown.tsx +++ b/src/components/navbar/DropDown.tsx @@ -1,35 +1,18 @@ -"use client"; - -import { useRef } from "react"; -import { useOnClickOutside } from "usehooks-ts"; import DropDownLink from "./DropDownLink"; export default function DropDown({ name }: { name: string }) { - const ref = useRef(null); - - const handleClick = () => { - if (ref.current) { - ref.current.open = !open; - } - }; - - useOnClickOutside(ref, () => handleClick()); return ( -
- - {name} - -
    -
  • - - -
  • +
    + +
      + +
    -
+ + ); } diff --git a/src/components/navbar/DropDownLink.tsx b/src/components/navbar/DropDownLink.tsx index 88928282..9cafb78d 100644 --- a/src/components/navbar/DropDownLink.tsx +++ b/src/components/navbar/DropDownLink.tsx @@ -3,21 +3,20 @@ import Link from "next/link"; interface DropDownLinkProps { title: string; href?: string; - handleClick: () => void; } export default function DropDownLink({ title, href = "#", - handleClick, }: DropDownLinkProps) { return ( - - {title} - +
  • + + {title} + +
  • ); } diff --git a/src/components/navbar/Navbar.tsx b/src/components/navbar/Navbar.tsx index 7c39e644..8b57aeca 100644 --- a/src/components/navbar/Navbar.tsx +++ b/src/components/navbar/Navbar.tsx @@ -12,8 +12,8 @@ export default function Navbar() {
    -
      -
    • +
        +
      • diff --git a/yarn.lock b/yarn.lock index 53747c02..2da95ee2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5633,11 +5633,6 @@ use-sync-external-store@^1.0.0: resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.0.tgz#7dbefd6ef3fe4e767a0cf5d7287aacfb5846928a" integrity sha512-eEgnFxGQ1Ife9bzYs6VLi8/4X6CObHMw9Qr9tPY43iKwsPw8xE8+EFsf/2cFZ5S3esXgpWgtSCtLNS41F+sKPA== -usehooks-ts@^2.9.1: - version "2.9.1" - resolved "https://registry.yarnpkg.com/usehooks-ts/-/usehooks-ts-2.9.1.tgz#953d3284851ffd097432379e271ce046a8180b37" - integrity sha512-2FAuSIGHlY+apM9FVlj8/oNhd+1y+Uwv5QNkMQz1oSfdHk4PXo1qoCw9I5M7j0vpH8CSWFJwXbVPeYDjLCx9PA== - util-deprecate@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"