问题描述
我正在尝试将 @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 (将#修改为@)