12

I need Tooltip component from two libraries. For example

import { Tooltip } from "react-leaflet";
import { Tooltip } from "recharts";

But the same name of Tooltip of two libraries, I get an error. How to import Tooltip without error.

2 Answers 2

23
import { Tooltip as LeafletTooltip } from "react-leaflet";

And then using <LeafletTooltip> below

11
import { Tooltip as ReactLeafletTooltip} from "react-leaflet";
import { Tooltip as RechartsTooltip} from "recharts";

then use it in render as

<RechartsTooltip/>
<ReactLeafletTooltip/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.