how to use useState in turborepo ui package component such that it works as client component

when I add a useState to https://github.com/vercel/turbo/blob/main/examples/with-tailwind/packages/ui/src/Button.tsx , I get this error You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default., but I'm seeing that a useState is used just fine here https://github.com/vercel/turbo/blob/main/examples/kitchen-sink/packages/ui/src/CounterButton.tsx . I, then, saw https://github.com/vercel/turbo/blob/main/examples/kitchen-sink/packages/ui/tsup.config.ts that there's a "banner" property with use client so I tried to add this property, but it doesn't fix it. how do I fix it?
GitHub
turbo/Button.tsx at main · vercel/turbo
Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo. - turbo/Button.tsx at main · vercel/turbo
GitHub
turbo/CounterButton.tsx at main · vercel/turbo
Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo. - turbo/CounterButton.tsx at main · vercel/turbo
GitHub
turbo/tsup.config.ts at main · vercel/turbo
Incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust – including Turbopack and Turborepo. - turbo/tsup.config.ts at main · vercel/turbo
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server