Skip to content

Commit

Permalink
Memoize Coordinates.Cartesian pattern ID
Browse files Browse the repository at this point in the history
This should help avoid unnecessary re-renders.
  • Loading branch information
stevenpetryk committed May 8, 2024
1 parent 009c7b8 commit c18dfef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/display/Coordinates/Cartesian.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as React from "react"
import { range, round } from "../../math"
import { usePaneContext } from "../../context/PaneContext"
import { useTransformContext } from "../../context/TransformContext"
Expand Down Expand Up @@ -26,7 +27,7 @@ export function Cartesian({
const xAxis = { subdivisions, ...defaultAxisOptions, ...xAxisOverrides } as GridAxisOptions
const yAxis = { subdivisions, ...defaultAxisOptions, ...yAxisOverrides } as GridAxisOptions

const id = `cartesian-${incrementer++}`
const id = React.useMemo(() => `cartesian-${incrementer++}`, [])

const { viewTransform } = useTransformContext()
const { xPaneRange, yPaneRange } = usePaneContext()
Expand Down

0 comments on commit c18dfef

Please sign in to comment.