Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

dynamic classes in react

render () {

var btnClass = classNames({
  'btn': true,
  'btn-pressed': this.state.isPressed,
  'btn-over': !this.state.isPressed && this.state.isHovered
});

return <button className={btnClass}>I'm a button!</button>;

}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dynamic #classes #react
ADD COMMENT
Topic
Name
6+2 =