Skip to content

Commit 8159ec3

Browse files
committed
error fix for button component and linkButton component
1 parent f6f53b4 commit 8159ec3

2 files changed

Lines changed: 18 additions & 44 deletions

File tree

src/components/Button/Button.tsx

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,17 @@
11
import React from 'react';
22

3-
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4-
children: React.ReactNode;
5-
name: string;
6-
}
3+
type ButtonProps = React.ComponentProps<typeof Button>;
74

8-
const Button: React.FC<ButtonProps> = ({ children, name, ...props }) => {
5+
const Button: React.FC<ButtonProps> = ({ children, ...props }) => {
6+
console.log(props);
97
return (
10-
<>
11-
<button
12-
type="button"
13-
name={name}
14-
{...props}
15-
className="p-4 px-8 text-white font-bold bg-red-600 rounded"
16-
style={{
17-
display: 'block',
18-
width: '200px',
19-
overflow: 'hidden',
20-
whiteSpace: 'nowrap',
21-
textOverflow: 'ellipsis',
22-
textAlign: 'center',
23-
}}
24-
>
25-
{children}
26-
</button>
27-
</>
8+
<button
9+
type="button"
10+
className="p-4 px-8 text-white font-bold bg-red-600 rounded block w-[200px] overflow-hidden whitespace-nowrap overflow-ellipsis text-center"
11+
{...props}
12+
>
13+
{children}
14+
</button>
2815
);
2916
};
3017

src/components/LinkButton/LinkButton.tsx

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
import React from 'react';
22

3-
interface LinkProps extends React.HTMLProps<HTMLAnchorElement> {
4-
children: React.ReactNode;
5-
to: string;
6-
}
3+
type LinkButtonProps = React.Component<'a'>;
74

8-
const LinkButton: React.FC<LinkProps> = ({ to, children, ...props }) => {
5+
const LinkButton: React.FC<LinkButtonProps> = ({ children, ...props }) => {
96
return (
10-
<>
11-
<a
12-
href={to}
13-
{...props}
14-
className="p-2"
15-
style={{
16-
width: '100px',
17-
overflow: 'hidden',
18-
whiteSpace: 'nowrap',
19-
textOverflow: 'ellipsis',
20-
textAlign: 'center',
21-
}}
22-
>
23-
{children}
24-
</a>
25-
</>
7+
<a
8+
className="p-4 px-8 text-white font-bold bg-red-600 rounded block w-[200px] overflow-hidden whitespace-nowrap overflow-ellipsis text-center"
9+
{...props}
10+
>
11+
{children}
12+
</a>
2613
);
2714
};
2815

0 commit comments

Comments
 (0)