Skip to content

Commit 5985ab4

Browse files
authoredJun 17, 2022
fix(sankey): include link's index in the React Component key when creating the SVG element (#2037)
* Include link's index in the react's key prop This is to support custom color gradients for multiple links between the same two nodes. Also prevents the duplicate child key error when 2+ links attach to the same two nodes. * Include Sankey link's index in the gradient id Support custom color gradients for multiple links between the same two nodes.
1 parent b78c3d1 commit 5985ab4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
 

‎packages/sankey/src/SankeyLinks.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const SankeyLinks = <N extends DefaultNode, L extends DefaultLink>({
5959
<>
6060
{links.map(link => (
6161
<SankeyLinksItem<N, L>
62-
key={`${link.source.id}.${link.target.id}`}
62+
key={`${link.source.id}.${link.target.id}.${link.index}`}
6363
link={link}
6464
layout={layout}
6565
path={getLinkPath(link, linkContract)}

‎packages/sankey/src/SankeyLinksItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const SankeyLinksItem = <N extends DefaultNode, L extends DefaultLink>({
3232
isInteractive,
3333
onClick,
3434
}: SankeyLinksItemProps<N, L>) => {
35-
const linkId = `${link.source.id}.${link.target.id}`
35+
const linkId = `${link.source.id}.${link.target.id}.${link.index}`
3636

3737
const { animate, config: springConfig } = useMotionConfig()
3838
const animatedPath = useAnimatedPath(path)

0 commit comments

Comments
 (0)
Please sign in to comment.