How to wrap up Ant Design with Styled Components and TypeScript?

前端 未结 5 1537
独厮守ぢ
独厮守ぢ 2021-02-13 15:47

I want to wrap up my ant-design components with styled-components, I know that this is possible (https://gist.github.com/samuelcastro/0ff7db4fd54ce2b80cd1c34a85b40c08) however I

5条回答
  •  广开言路
    2021-02-13 16:33

    The root of the problem seems to be that styled-components expects the inner component (AntButton) to accept all the props in the specified interface (IButtonProps), but AntButton does not accept customProp. To fix this, follow the last example in this section of the documentation and use a stateless function component to remove customProp before calling AntButton.

    export const Button = styledComponents(
      ({ customProp, ...rest }) => )`
      // any custom style here
    `;
    

提交回复
热议问题