1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

React(es2015) class(css)に関するメモ

Last updated at Posted at 2016-09-20

classの指定

htmlでは、classだが、classNameで指定

react.js

class Sample extends Component {
  render() {
    return (
      <div className="class_name">
        xx
      </div>
    )
  }
}

classをクリックに合わせて変更する場合

下記のように、onClickと絡めることで、クリックされたタイミングで、classNameを変更することができる。

react.js
class Menu extends Component {
  render() {
    return (
    <nav className="mdl-navigation">
      <a onClick={() => {
        browserHistory.push("/add");
        document.getElementById("menu").className = 'mdl-layout__drawer';
      }} className="mdl-navigation__link">追加</a>
      </nav>
    );
  }
}
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?