所以我正在为这家公司构建一个设计系统,并且组件系统在设计系统故事书中正确显示。但是当我将其导入消费者应用程序时,出现以下错误
TypeError: Cannot read property 'width' of undefined in theme.border.width
Run Code Online (Sandbox Code Playgroud)
/// src/components/Button/index.js
import { Wrapper } from './styles'
import React from 'react'
export const Button = (props) => (
<Wrapper {...props}>
{children}
</Wrapper>
)
Run Code Online (Sandbox Code Playgroud)
。
///src/components/Button/styles.js
export const Wrapper = styled.button`
...
border-width: ${({theme}) => theme.border.width};
...
`
Run Code Online (Sandbox Code Playgroud)
。
/// .storybook/preview.js
import React from 'react'
import { ThemeProvider } from 'styled-components'
import { GlobalStyle } from '../src/styles/globalStyles'
import { theme } from '../src/styles/theme'
export const parameters = {
actions: …Run Code Online (Sandbox Code Playgroud)