我试图在Legend组件悬停时显示工具提示。为此,我有一个Father带有useState钩子的Map组件,以便将数组的索引传递给 Leaflet组件,Location并在Permanent这些索引相等时更改属性。
const permanent = i === showLocationPosition;
该showLocationPosition是针对越来越悬停,通过props的获取位置索引Father组件。
<Marker
position={[position[0], position[1]]}
key={index}
icon={divIcon({ className: 'marker-dot dot-hover', html: ReactDOMServer.renderToString(stringHTML), iconSize: [30, 30] })}
>
<Tooltip direction="bottom" opacity={1} offset={new Point(xPoint, 10)} permanent={permanent}>
<div className={`popup-container-header ${item.count ? 'w-80' : 'w-40 text-center'}`}>
<p className="w-full">
{type_of_country_operation ?? item.name}
</p>
{item.count && <p>{item.count}</p>}
</div>
{item.summary && <p className="popup-container-main">{item.summary}</p>}
</Tooltip>
</Marker>
我可以验证permanent变量发生了变化,但Tooltip没有出现。
有什么建议吗?谢谢!