Skip to content
This repository was archived by the owner on May 25, 2026. It is now read-only.

feat: created new component button#2

Open
Joao-Manuel-S-M wants to merge 2 commits into
he4rt:mainfrom
Joao-Manuel-S-M:feature/button
Open

feat: created new component button#2
Joao-Manuel-S-M wants to merge 2 commits into
he4rt:mainfrom
Joao-Manuel-S-M:feature/button

Conversation

@Joao-Manuel-S-M
Copy link
Copy Markdown

Comment thread src/components/Button/Button.types.ts Outdated

export interface ButtonProps {
label: string;
onClick: () => void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu considero declarar os event handlers manualmente como um anti pattern, a gente perde a tipagem de coisas importantes. Eu prefiro fazer dessa forma (usando type e union):

import { ButtonHTMLAttributes } from "react"

export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
   // Props personalizadas aqui
   label: string;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread tsconfig.json
Comment thread src/components/Button/Button.tsx Outdated
Comment on lines +5 to +6
export const Button = ({label, onClick}:ButtonProps) => {
return <S.Button onClick={onClick}>{label}</S.Button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Com as mudanças que propus na tipagem, você terá que utilizar todas as props default do botão e repassar para o componente. Dessa forma:

Suggested change
export const Button = ({label, onClick}:ButtonProps) => {
return <S.Button onClick={onClick}>{label}</S.Button>
export const Button = ({label, ...props}:ButtonProps) => {
return <S.Button {...props}>{label}</S.Button>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entendi! Eu e o Mov conversamos na hora essa possibilidade e decidimos optar por uma forma mais simples e clara pra explicar pra eles. Vale depois a gente precisa trocar uma ideia e chegar em um concenso sobre aprofundamos mais (com isso aumenta a complexidade e abaixa a compreenção do conhecimento) pra aumentar a qualidade.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants