For some reason, react-tooltip is rendering 2 tooltips, when I only asked it to render one (of course), here is an example on one of my react components:
However, it shouldn't be, as the code only renders it once. Let me show you the react code:
import React from "react";
import ReactTooltip from "react-tooltip";
import "./StaffMembers.scss";
import ProfileIcon from "../public/profile.svg";
function getKeysAndValues<T>(item: T[]) {
return Array.from(item.entries());
}
export interface StaffDetails {
pfp: string;
email: string;
}
const StaffMembers: React.FC<{ staff: StaffDetails[] }> = (props) => {
return (
<>
<div className="staffMembers">
<h1 className="title">All Staff Members</h1>
<div className="staffTable">
{getKeysAndValues(props.staff).map(([id, staff]) => (
<div className="staffMember" key={id}>
<div className="userDetail">
<img
className="pfp"
src={staff.pfp}
alt="pfp"
/>
<p className="email" data-tip={staff.email}>
{staff.email}
</p>
</div>
<button className="copyBtn">Copy UID</button>
<button className="logoutBtn">Log-out</button>
</div>
))}
</div>
</div>
<ReactTooltip />
</>
);
};
export default StaffMembers;
And the SCSS for that component:
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;400;500&display=swap');
.staffMembers::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
border-radius: 10px;
background-color: #F5F5F5;
}
.staffMembers::-webkit-scrollbar {
width: 12px;
background-color: #F5F5F5;
}
.staffMembers::-webkit-scrollbar-thumb {
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
background-color: #555;
}
.staffMembers {
background: #FEFEFF;
border: 3px solid rgba(217, 217, 217, 0.5);
box-sizing: border-box;
border-radius: 10px;
width: 450px;
display: flex;
flex-direction: column;
align-items: center;
.title {
font-family: Poppins;
font-style: normal;
font-weight: normal;
font-size: 24px;
line-height: 36px;
text-align: center;
padding: 20px;
color: #000000;
}
.staffTable {
width: 100%;
border-top: 1px solid rgba(217, 217, 217, 0.5);
border-collapse: collapse;
display: flex;
flex-direction: column;
max-height: 350px;
display: block;
overflow-y: auto;
white-space: nowrap;
}
.staffMember {
border-bottom: 1px solid rgba(217, 217, 217, 0.5);
display: flex;
align-items: center;
justify-content: space-around;
}
.userDetail {
font-family: Poppins;
font-style: normal;
font-weight: normal;
font-size: 14px;
display: flex;
align-items: center;
flex-direction: row;
}
.pfp {
height: 41px;
}
.email {
margin-left: 15px;
width: 150px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.copyBtn {
border: 0;
background: #7EDD7E;
border-radius: 5px;
font-family: Poppins;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 18px;
/* identical to box height */
text-align: center;
color: #000000;
height: 25px;
}
.logoutBtn {
border: 0;
background: #FA2C2C;
border-radius: 5px;
font-family: Poppins;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 18px;
/* identical to box height */
text-align: center;
color: #000000;
height: 25px;
}
}
I cannot quite figure out what the hell is going wrong - as I am only calling the data-tip prop once on the <p> tag.
Thanks for the help.
