Created
March 19, 2018 11:35
-
-
Save Jahans3/2b0fc5d139ea9b7175f7f64e54fcc00e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Component JS file | |
import React from 'react' | |
import s from './style.scss' // <--- Imported into JS file | |
const SomeComponent = () => ( | |
<div className={s.container}> // <---- Can use more simple classes as they're automatically name-spaced | |
<span className={s.text}>Hello!</span> | |
</div> | |
) | |
// CSS file | |
.container { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.text { | |
color: green; | |
} | |
/*------------------------------------------------------------*/ | |
// Component JS file | |
import React from 'react' | |
// <--- No import, included via main.css | |
const SomeComponent = () => ( | |
<div className='some-container'> // <--- Need to name-space classes to avoid collisions | |
<span className='some-text'>Hello!</span> | |
</div> | |
) | |
// styles.scss | |
.some-container { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.some-text { | |
color: green; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment