How to import two component but same name from two libraries?
Asked Answered
R

2

11

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.

Readable answered 28/4, 2018 at 8:1 Comment(0)
C
22
import { Tooltip as LeafletTooltip } from "react-leaflet";

And then using <LeafletTooltip> below

Curitiba answered 28/4, 2018 at 8:8 Comment(0)
R
11
import { Tooltip as ReactLeafletTooltip} from "react-leaflet";
import { Tooltip as RechartsTooltip} from "recharts";

then use it in render as

<RechartsTooltip/>
<ReactLeafletTooltip/>
Ridotto answered 28/4, 2018 at 8:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.