Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

set meterial icon color change onClick react

class Utilitybar extends React.Component {
  constructor(props) {
    super(props)
    this.onButtonClicked = this.onButtonClicked.bind(this)
    this.state = { currentButton: null }
  }

  onButtonClicked (id) {
    this.setState({ currentButton: this.state.currentButton === id ? null : id })
  }

  render(){
    return (
      <div>
        <IconButton
          color={this.state.currentButton === 0 ? "primary" : "default" }
          onClick={() => this.onButtonClicked(0)}>
          <FaPlayCircle/>
        </IconButton>
        <IconButton
          color={this.state.currentButton === 1 ? "primary" : "default" }
          onClick={() => this.onButtonClicked(1)}>
          <FaRegFileAlt/>
        </IconButton>
      </div>
    );
  }
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: reisze image expo react native 
Javascript :: stringy 
Javascript :: add a class in react 
Javascript :: auto generate component angular 
Javascript :: Uncaught TypeError: $(...).datatables is not a function 
Javascript :: iterating over a string 
Javascript :: vue js override component css 
Javascript :: != javascript 
Javascript :: js if and operator 
Javascript :: console.log() Syntax 
Javascript :: window parent frames js 
Javascript :: what is middleware in express js 
Javascript :: classes in javascript mdn 
Javascript :: pass function with parameter as prop 
Javascript :: object to string js 
Javascript :: Recursion In DOM 
Javascript :: create object javascript 
Javascript :: react places autocomplete 
Javascript :: set visible vue 
Javascript :: Find the count of a letter in a string 
Javascript :: react scroll animation 
Javascript :: Use the parseInt Function with a Radix Javascript 
Javascript :: jquery modal popup 
Javascript :: queryselector multiple attributes 
Javascript :: three js 
Javascript :: slot vuetify js 
Javascript :: nodejs ecommerce cms 
Javascript :: create text node in javascript 
Javascript :: reactjs debounce 
Javascript :: javascript continue with while Loop 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =