Primitives support (for) styled components令人兴奋......安装后我在浏览器中收到此错误:
TypeError: __WEBPACK_IMPORTED_MODULE_1_styled_components_primitives___default.a.div is not a function
Object.__webpack_exports__.a
src/App.js:13
10 | })
11 |
12 | //const styled = styled.default;
> 13 | const Body = styled.div`
仅当将 import 设置为 import styled from 'styled-components' 时才会显示此错误运行 create-react-app 后。
应用程序.js
import React from 'react'
import styled from 'styled-components/primitives'
import WebFont from 'webfontloader'
WebFont.load({
google: {
families: ['Bungee+Shade', 'Roboto', 'Nixie+One', 'Muli']
}
})
//const styled = styled.default;
const Body = styled.div`
安装/s 似乎没问题???
纱线添加样式组件反应基元
yarn add v0.24.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.0.17: The platform "linux" is incompatible with this module.
info "fsevents@1.0.17" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Your current version of Yarn is out of date. The latest version is "0.24.6" while you're on "0.24.5".
info To upgrade, run the following command:
$ npm upgrade --global yarn
success Saved 2 new dependencies.
├─ react-primitives@0.4.2
└─ styled-components@2.1.0
Done in 118.88s.