victory
victory copied to clipboard
Type Error in Victory Container 36.9.1
I am using victory 36.9.1
and react 18.2
in node 20
It is all working in production currently on node 16, react 17 using victory 35.4.8
I am trying to create a voronoi zoom container
import { VictoryVoronoiContainerProps } from 'victory-voronoi-container';
import { VictoryZoomContainerProps } from 'victory-zoom-container';
When I create the container I get a type error:
const VictoryZoomVoronoiContainer = createContainer<VictoryZoomContainerProps, VictoryVoronoiContainerProps>(
'zoom',
'voronoi',
);
Expected 0 type arguments, but got 2.ts(2558)
Apologies in advance if this is my fault and is a question best directed elsewhere.
Originally posted by @eatyourpeas in https://github.com/FormidableLabs/victory/issues/1446#issuecomment-1950179439
The types for this function have been rewritten here #2799
In fact I managed to get this working in the end with this (note, breaks without the any
):
// allows two top level containers: zoom and voronoi
const VictoryZoomVoronoiContainer:any = createContainer(
'zoom',
'voronoi',
);
Feels like I have not understood the types magic that is going on here, but this works for me for the moment, unless there is some better way I should do this.
to get the same type as before the change that broke this you can temporarily use
const VictoryZoomVoronoiContainer = createContainer('zoom', 'voronoi') as React.ComponentType<
VictoryVoronoiContainerProps & VictoryZoomContainerProps
>