Material-UI:以编程方式触发悬停效果

我正在Material-UI我的应用程序中呈现以下组件:


const handleSetActive = _spyOn => {

  linkEl.current.focus();

};


const linkEl = useRef(null);


return (

    <ListItem

      button

      component={SmoothScrollLink}

      to={cutTo}

      spy

      smooth

      offset={(phone ? -theme.mixins.toolbar.minHeightPhone : -theme.mixins.toolbar.minHeightDesktop) - 20}

      duration={500}

      onSetActive={handleSetActive}

      // className={classNames(spyOn === cutTo && classes.hover)}

      ref={linkEl}

      {...other}

    />

)

它正在使用react-scroll包,onSetActive只要滚动经过该特定ListItem.


我想以最简单的方式使ListItem(来自 Material-UI)在handleSetActive触发时启用其悬停效果。


我怎样才能最好地做到这一点?


手掌心
浏览 183回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript