I want to override a Button Ant Design with typescript and styled component to personalize the style. But when I try te result is not good.
I try some test but never I have the good display.
I try like this How to wrap up Ant Design with Styled Components and TypeScript? but no result.
But the result haven't the style of ant Design component but the button inherite the Button ant design and her props.
ButtonStyledComponent
import { Button as AntButton } from "antd";
import { NativeButtonProps } from "antd/lib/button/button";
import * as React from "react";
import styledComponents from "styled-components";
export const Button = styledComponents<NativeButtonProps>(props => (
<AntButton {...props} />
))`
pType: string;
pSize: string;
pShape: string;
`;
Button
import * as React from "react";
import { Button } from "./ButtonStyleComponent";
export interface ButtonProps {
pType?: "primary" | "secondary" | "danger";
pSize?: "small" | "medium" | "large";
pShape?: "round" | "rect";
}
class Button extends React.Component<ButtonProps> {
render() {
return (
<Button
{...this.props}
pType={this.props.pType}
pSize={this.props.pSize}
pShape={this.props.pShape}
>
{this.props.children}
</Button>
);
}
}
export { Button };
the problem is when I execute this code, I see just an ugly grey Button and not a Button with the design of the Ant Design Button.
The other problem is when I try to call the method of a Ant Design Button, the method is not recognize (ex: the method onClick ).