Change color React

Viewed 39

need some help, when i click to the links, it choose all of them what shoud i do? And another thing how to remove this click?

export default class Nav extends Component {
state = {
    colorBg: ''
  };
  handleClick(e) {
    this.setState({ colorBg: 'yellow' });
  }

render() {
    let styles = {};
    if (this.state.colorBg) {
      styles.backgroundColor = this.state.colorBg;
    }
    return (
        <nav className={s.nav}>
            <img className={s.logo} src={logo} alt="broma" />
            <ul className={s.containerUl} >
                <li className={s.link} style={ styles } onClick={ () => this.handleClick() }>
                   <a href="#">main</a></li>
                <li className={s.link} style={styles}  onClick={ () => this.handleClick()}><a href="#">about</a></li>
                <li className={s.link} onClick={ this.handleClick }>docs</li>
                <li className={s.link} onClick={ this.handleClick }>settings</li>
            </ul>
        </nav>
    )
}

}

0 Answers
Related