LoginSignup
4
3

More than 5 years have passed since last update.

React CSS moudulesでclassNameを複数渡す

Last updated at Posted at 2017-02-17

React CSS moudulesでclassNameを複数渡す

※備忘録

React CSS moudulesでclassNameを複数渡すやりかた
テンプレートリテラルを利用して複数渡す

import { 
  hoge,
  active
} from './style.css'


// className切替
const classNameSwitch = (active) => {
  if(active){
     return `${hoge} ${active}`
  } else {
     return hoge
  }
};


const App = ({active}) => (
  <div className={classNameSwitch(active)}>
    hoge
  </div>
);

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3