airbnb / airbnb/react-with-styles
Cannot read property 'create' of undefined
- Dominant language
- JavaScript
- Stars
- 1.7k
- Forks
- 101
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting `Cannot read property 'create' of undefined` and don't know why. I followed the examples and still getting this.
``` js
// theme.js
export default {
color: {
primary: '#FF5A5F',
secondary: '#00A699'
}
}
```
```js
// styles.js
import ThemedStyleSheet from 'react-with-styles/lib/ThemedStyleSheet'
import { css, withStyles } from 'react-with-styles'
import MyTheme from './theme'
ThemedStyleSheet.registerTheme(MyTheme)
export { css, withStyles, ThemedStyleSheet }
```
```js
// index.js
import React from 'react'
import PropTypes from 'prop-types'
import { css, withStyles } from './styles'
function MyComponent({ styles }) {
return (
)
}
MyComponent.propTypes = {
styles: PropTypes.object.isRequired
}
export default withStyles(({ color }) => ({
firstLink: {
color: color.primary
},
secondLink: {
color: color.secondary
}
}))(MyComponent)
```
If I export like this
```js
export default withStyles()(MyComponent)
```
it works just fine, but I don't have the styles.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the error with the supplied theme.js, styles.js, and index.js examples, then inspect the react-with-styles imports and ThemedStyleSheet.registerTheme call. Done means identifying why the styled callback receives an undefined value and documenting or verifying a working configuration that preserves the requested styles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100