由于您尚未共享代码,因此这里是无状态组件 react-tooltip
import React from "react";
import ReactTooltip from 'react-tooltip'
import {Link} from "react-router-dom"
const UserActionLink = ({to,tooltip,alignRight,btnClassname,iconClassname,name,toolTipName}) =>{
const buttonClassname = btnClassname ? " btn mx-2 " + btnClassname : " btn mx-2 "
const iconsClassname = iconClassname ? " fa " + iconClassname : " fa "
const align = alignRight ? " float-right " : " float-left "
return (
<span>
<Link className={[buttonClassname , align ].join(' ')} data-tip={toolTipName} to={to}>
<i className={iconsClassname} aria-hidden="true"></i> {name}
</Link>
<ReactTooltip />
</span>
);
}
export default UserActionLink
编辑
这是工作代码:
<div className="customTooltip">
<ReactTooltip effect="solid">
{'I shall be the text and this is where I will go'}
</ReactTooltip>
</div>
.customTooltip .__react_component_tooltip.place-top{
margin-top:0 !important;
}
.customTooltip .__react_component_tooltip.type-dark{
background-color: #e6bd32;
}
.customTooltip .__react_component_tooltip.type-dark.place-top:after {
border-top-color: #d2ac2d;
border-top-style: solid;
border-top-width: 6px;
}