我刚刚安装了该styled-components
库并开始使用它。
但是这个简单的例子:
import React from 'react'
import styled from 'styled-components'
const Div = styled.div`background: red;`
const AlertCard = () => (
<Div>Hello World</Div>
)
export default AlertCard
和渲染功能:
render() {
const { fetchingAlerts, alerts } = this.props
return (
fetchingAlerts ?
<Loader /> :
<div>
<AlertFormContainer />
<div>
{alerts.length === 0 ?
<EmptyAlerts /> :
<div>
{alerts.map(alert => (
<AlertCard text="My text " />
))}
</div>
}
</div>
</div>
)
)
}
触发此错误: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
样式组件返回一个对象 $$typeof: Symbol(react.element)
我不知道出了什么问题