Skip to content

Commit

Permalink
fix(bar): avoid to redefine react forwardRef type
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrien Gibrat authored and plouc committed Dec 17, 2021
1 parent edd3990 commit cd6e3ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 0 additions & 7 deletions packages/bar/src/BarCanvas.tsx
Expand Up @@ -27,13 +27,6 @@ import { renderLegendToCanvas } from '@nivo/legends'
import { useTooltip } from '@nivo/tooltip'
import { useBar } from './hooks'

declare module 'react' {
// eslint-disable-next-line @typescript-eslint/ban-types
function forwardRef<T, P = {}>(
render: (props: P, ref: React.Ref<T>) => React.ReactElement | null
): (props: P & React.RefAttributes<T>) => React.ReactElement | null
}

type InnerBarCanvasProps<RawDatum extends BarDatum> = Omit<
BarCanvasProps<RawDatum>,
'renderWrapper' | 'theme'
Expand Down
7 changes: 6 additions & 1 deletion packages/bar/src/ResponsiveBarCanvas.tsx
Expand Up @@ -9,7 +9,12 @@ export const ResponsiveBarCanvas = forwardRef(function ResponsiveBarCanvas<
return (
<ResponsiveWrapper>
{({ width, height }) => (
<BarCanvas width={width} height={height} {...props} ref={ref} />
<BarCanvas
width={width}
height={height}
{...(props as Omit<BarCanvasProps<BarDatum>, 'height' | 'width'>)}
ref={ref}
/>
)}
</ResponsiveWrapper>
)
Expand Down

0 comments on commit cd6e3ec

Please sign in to comment.