gajus / gajus/babel-plugin-react-css-modules
Cannot Resolve Stylename If not explicitly a String
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 159
- PR merge metrics
- No merged PRs in 30d
Description
Take the following code snippet:
```
render() {
const appliedStyles = ['one', 'two'];
appliedStyles.push(this.props.a ? 'style-a' : 'style-b');
return (
Hello
);
}
```
What you'll see is that we'll end up getting something like `Unhandled rejection Error: Could not resolve the styleName 'style-a'.`
However, if we change the code ever so slightly to
```
```
then it seems to work.
Is this a Babel constraint or a fixable bug? The pattern works with your [non-babel version](https://github.com/gajus/react-css-modules).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the supplied React snippet in babel-plugin-react-css-modules, comparing the array join expression with the template-literal form. Check how the Babel plugin resolves dynamic styleName expressions and compare the behavior with the linked non-Babel version; done means both forms resolve without the reported error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100