adrianhajdin / banking

Horizon is a modern banking platform for everyone.
https://banking-jet.vercel.app
MIT License
1.81k stars 546 forks source link

You're importing a component that needs usePathname. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default. #40

Open mriccelli75 opened 1 month ago

mriccelli75 commented 1 month ago

UsePathname in Sidebar component is throwing this error;

Error: × You're importing a component that needs usePathname. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default. │ Learn more: https://nextjs.org/docs/getting-started/react-essentials │ │ ╭─[/Users/mriccelli75/Sites/jsm_banking/components/Sidebar.tsx:4:1] 4 │ import Link from 'next/link' 5 │ import Image from 'next/image' 6 │ import { sidebarLinks } from '@/constants' 7 │ import { usePathname } from 'next/navigation' · ─────────── 8 │ 9 │ 10 │ const Sidebar = ({user}: SiderbarProps) => { ╰────

Admeen3581 commented 1 month ago

Where is your 'use client' markup? If you can, paste your Sidebar.tsx file. @mriccelli75

Armelrik commented 1 month ago

You might add use client on top of your file to sort this issue in Nextjs.

"use client"; // This is a client component