ul li mouse move in and out change, click change

Foreword: I recently wrote a small module of ul li, so simple, it actually made me work hard, and I haven't written this kind of thing for a long time. The small details of the ui are also quite tortured.

need:

The original thought was that the background color of the ul-li changes when the mouse moves in and out.

Finally confirmed the requirements, after changing to click, the background color changes.

<li
                            key={item.id}
                            className={styles['wmx-group-left-list__li']}
                            style={
   
   { background: currentRow.id === item.id ? '#FEF6D8' : '#fff' }}
                            onClick={() => getCurrentRow(item, index)}
                          >

The main thing is that there is a getCurrentRow method when clicking to get the currently clicked li,

  const getCurrentRow = (item, index) => {
    if (!checkboxShow) {
      setCurrentRow(item);
      setCurrentIndex(index);
    }

  };

Then, when judging by style, the background color will change.

Guess you like

Origin blog.csdn.net/chhpearl/article/details/126711902