如何将 React.forwardRef 与 @material/react-ripple 一起使用?

问题描述

我正在尝试将 @material/react-ripple 添加到我的按钮中。 我预先存在的组件使用 React.forwardRef((props,ref) => ...)

然而,@material/react-ripple(根据自述文件)想要控制我的引用(注意 initRipple):

import {withRipple} from '@material/react-ripple';

const Icon = (props) => {
  const {
    children,className = '',// You must call `initRipple` from the root element's ref. This attaches the ripple
    // to the element.
    initRipple,// include `unbounded` to remove warnings when passing `otherProps` to the
    // root element.
    unbounded,...otherProps
  } = props;

  // any classes needed on your component needs to be merged with
  // `className` passed from `props`.
  const classes = `ripple-icon-component ${className}`;

  return (
    <div
      className={classes}
      ref={initRipple}
      {...otherProps}>
      {children}
    </div>
  );
};

我怎样才能解决这个问题,并保持我的参考转发能力?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...