0

我想使用styled-components创建一个可重用的“IconButton”来扩展Rebass Button,但我收到了这个警告:

Unknown props 'small, 'overlay' on <button> tag. Remove these props from the element

如何从元素中删除这些道具?

export default ({
  ...props,
  type,
  action,
  top,
  small,
  overlay
}) =>
  <IconButton
    onClick={() => action()}
    px={3}
    mt={top && 2}
    small={small}
    overlay={overlay}>
    {Icons[type]()}
  </IconButton>;

const IconButton = styled(Button)`
  background: ${({ overlay }) => (overlay ? "white" : "transparent")};
  svg {
    height: ${props =>
      props.small ? props.theme.fontSizes[4] : props.theme.fontSizes[5]}px;
    width: ${props => props.theme.fontSizes[5]}px;
  }
`;
4

0 回答 0