refactor: replace button elements with Button component

This commit is contained in:
Anish Sarkar 2026-05-14 14:46:48 +05:30
parent da55c75e5e
commit 13b2e874f6
7 changed files with 38 additions and 16 deletions

View file

@ -12,6 +12,8 @@ Don't subscribe to dynamic state (searchParams, localStorage) if you only read i
**Incorrect (subscribes to all searchParams changes):**
```tsx
import { Button } from '@/components/ui/button'
function ShareButton({ chatId }: { chatId: string }) {
const searchParams = useSearchParams()
@ -20,13 +22,15 @@ function ShareButton({ chatId }: { chatId: string }) {
shareChat(chatId, { ref })
}
return <button onClick={handleShare}>Share</button>
return <Button onClick={handleShare}>Share</Button>
}
```
**Correct (reads on demand, no subscription):**
```tsx
import { Button } from '@/components/ui/button'
function ShareButton({ chatId }: { chatId: string }) {
const handleShare = () => {
const params = new URLSearchParams(window.location.search)
@ -34,6 +38,6 @@ function ShareButton({ chatId }: { chatId: string }) {
shareChat(chatId, { ref })
}
return <button onClick={handleShare}>Share</button>
return <Button onClick={handleShare}>Share</Button>
}
```