【问题标题】:Style custom components using styled-components, React and Flow使用 styled-components、React 和 Flow 设置自定义组件的样式
【发布时间】:2018-08-08 10:06:04
【问题描述】:

我正在使用 React + Flow 构建应用程序,但我遇到了一个愚蠢的样式问题。

基本上,我已经(恢复):

import styled from 'styled-components';
import { Link } from 'react-router-dom';

export const Item = styled(Link)`
  some styling here
`;

我从 Flow 收到以下错误:

Cannot call `styled` because:
- Either a callable signature is missing in object type [1].
- Or a callable signature is missing in object type [2].

如何在不出现此错误的情况下为自己的组件设置样式?

谢谢!

【问题讨论】:

    标签: reactjs flowtype styled-components


    【解决方案1】:

    您可以创建一个组件并渲染一个Link 并将this.props.className 发送到prop classNameLink 组件。

    你可以在这段代码中看到MyLink组件:https://codesandbox.io/s/n03z3oq5vj

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 2020-07-10
      • 2021-10-02
      • 2020-08-31
      • 2021-11-04
      • 2021-07-16
      • 2021-09-19
      • 2020-07-07
      • 2021-12-06
      相关资源
      最近更新 更多