【发布时间】:2019-03-01 17:31:38
【问题描述】:
我有一个Field Formik 的组件,为了应用我做的自定义 CSS:
const Input = styled(Field)`
// CSS goes here
`
并使用Input 组件,工作正常。但是我在很多地方都使用完全相同的 CSS,所以我将这些 CSS 提取到名为SuperInput的独立样式组件@
现在,如何扩展样式组件?我需要类似的东西
const Input = styled(Field)`
// inlucde CSS from SuperInput component here
`
示例代码。
import styled from 'styled-components'
const SuperInput = styled.input`
// CSS here
`
import { Field } from 'formik'
import { SuperInput } from 'styled_components/super_input'
const SomeFormComponent = () => (
<>
// How to use here <Field /> that has <SuperInput /> CSS applied?
</>
)
【问题讨论】: