Skip to content

Commit

Permalink
fix(pie): use readonly arrays for props as the library does not modif…
Browse files Browse the repository at this point in the history
…y them
  • Loading branch information
pcorpet authored and plouc committed Nov 14, 2023
1 parent 5306106 commit 6dc6636
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/pie/src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useNormalizedData = <RawDatum extends MayHaveLabel>({
Omit<ComputedDatum<RawDatum>, 'arc' | 'color' | 'fill'>
>,
}: Pick<CompletePieSvgProps<RawDatum>, 'id' | 'value' | 'valueFormat' | 'colors'> & {
data: RawDatum[]
data: readonly RawDatum[]
}): Omit<ComputedDatum<RawDatum>, 'arc' | 'fill'>[] => {
const getId = usePropertyAccessor<RawDatum, DatumId>(id)
const getValue = usePropertyAccessor<RawDatum, number>(value)
Expand Down
10 changes: 5 additions & 5 deletions packages/pie/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export interface ComputedDatum<RawDatum> {
}

export interface DataProps<RawDatum> {
data: RawDatum[]
data: readonly RawDatum[]
}

export interface PieTooltipProps<RawDatum> {
Expand All @@ -73,7 +73,7 @@ export type MouseEventHandler<RawDatum, ElementType = HTMLCanvasElement> = (
export type PieLayerId = 'arcLinkLabels' | 'arcs' | 'arcLabels' | 'legends'

export interface PieCustomLayerProps<RawDatum> {
dataWithArc: ComputedDatum<RawDatum>[]
dataWithArc: readonly ComputedDatum<RawDatum>[]
centerX: number
centerY: number
radius: number
Expand Down Expand Up @@ -114,7 +114,7 @@ export type CommonPieProps<RawDatum> = {
isInteractive: boolean
tooltip: React.FC<PieTooltipProps<RawDatum>>

legends: LegendProps[]
legends: readonly LegendProps[]

role: string
renderWrapper: boolean
Expand All @@ -137,7 +137,7 @@ export type PieSvgProps<RawDatum> = DataProps<RawDatum> &
Partial<CommonPieProps<RawDatum>> &
SvgDefsAndFill<ComputedDatum<RawDatum>> &
PieHandlers<RawDatum, SVGPathElement> & {
layers?: PieLayer<RawDatum>[]
layers?: readonly PieLayer<RawDatum>[]
animate?: boolean
motionConfig?: MotionProps['motionConfig']
transitionMode?: ArcTransitionMode
Expand All @@ -148,7 +148,7 @@ export type CompletePieSvgProps<RawDatum> = DataProps<RawDatum> &
CommonPieProps<RawDatum> &
SvgDefsAndFill<ComputedDatum<RawDatum>> &
PieHandlers<RawDatum, SVGPathElement> & {
layers: PieLayer<RawDatum>[]
layers: readonly PieLayer<RawDatum>[]
animate: boolean
motionConfig: MotionProps['motionConfig']
transitionMode: ArcTransitionMode
Expand Down

1 comment on commit 6dc6636

@vercel
Copy link

@vercel vercel bot commented on 6dc6636 Nov 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nivo – ./

nivo-git-master-plouc.vercel.app
nivo-plouc.vercel.app
nivo.vercel.app
nivo.rocks
www.nivo.rocks

Please sign in to comment.