-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ability to forward refs in Bar and Path components
- Loading branch information
Cesar Perez
committed
Nov 13, 2023
1 parent
0a26400
commit 517f82b
Showing
2 changed files
with
14 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
import React from "react"; | ||
import React, { forwardRef } from "react"; | ||
import { VictoryPrimitiveShapeProps } from "./types"; | ||
|
||
export const Path = (props: VictoryPrimitiveShapeProps) => { | ||
// eslint-disable-next-line prefer-arrow-callback | ||
export const Path = forwardRef(function Path( | ||
props: VictoryPrimitiveShapeProps, | ||
ref, | ||
) { | ||
// eslint-disable-next-line react/prop-types | ||
const { desc, ...rest } = props; | ||
return desc ? ( | ||
// @ts-expect-error FIXME: "id cannot be a number" | ||
<path {...rest}> | ||
<path {...rest} ref={ref}> | ||
<desc>{desc}</desc> | ||
</path> | ||
) : ( | ||
// @ts-expect-error FIXME: "id cannot be a number" | ||
<path {...rest} /> | ||
<path {...rest} ref={ref} /> | ||
); | ||
}; | ||
}); |