-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use react CSS modules #204
Comments
my-app uses react-css-modules in create-react-app no work import React, {Component} from 'react';
import {immutableRenderDecorator} from 'react-immutable-render-mixin';
import CSSModules from 'react-css-modules';
import classnames from 'classnames';
import styles from '../css/style.scss';
// @immutableRenderDecorator
// @CSSModules(styles, {allowMultiple: true})
class lineBar extends Component {
render() {
const {left, width} = this.props;
console.log(styles,'@styles');
const classes = classnames({inkBar: true});
return (
<div styleName={classes}
style={{
WebkitTransform: `translate3d(${left}px, 0, 0)`,
transform: `translate3d(${left}px, 0, 0)`,
width: width
}}
>
</div>
)
}
}
export default immutableRenderDecorator(CSSModules(lineBar,styles, {allowMultiple: true})); error message:
log styles
|
Create React App does not use or support CSS Modules. You can eject and add them if you'd like. |
Great, recent article on using CSS Modules after ejecting Create React App: https://medium.com/nulogy/how-to-use-css-modules-with-create-react-app-9e44bec2b5c2 |
This article was a solution for getting CSS Modules, SASS, LESS and Stylus:
|
Note that |
exactly. the same issue with auth0-react-scripts. Shared forks considered
harmful.
2017-07-05 7:25 GMT+08:00 Dan Abramov <[email protected]>:
… Note that custom-react-scripts is not officially supported. It is
maintained by a community member.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#204 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACJsefVoSMRweRUfQCVvLLKeYBJpW3caks5sKsnUgaJpZM4JU4mJ>
.
|
I wouldn't say anything is "considered harmful", we actually appreciate the community publishing forks. I just want to make sure that people reading this thread in the future will have right expectations with regards to level of support we can provide. |
Hi gaearon, i'm wondering why css modules does not support in create-react-app. I think each component has own style. |
We might support it as opt-in in the future. We don't support it by default because it's not a standard syntax, some tools don't understand it, and it's very confusing to beginners who aren't used to importing specific classnames. |
Maybe add it as a option. |
@types into devDependencies
CSS modules are now supported. |
I assumed
create-react-app
uses react-css-modules, but this code does not work (no styles applied):It does, however, work when classes are defined as strings rather than scoped to this component. I think it wouldn't hurt to have this available for projects using create-react-app, what do you think?
The text was updated successfully, but these errors were encountered: