Skip to content

Commit f3fd74a

Browse files
add callback to useState
1 parent cbe0f20 commit f3fd74a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ui/SunburstChart/SunburstChart.jsx

+11-11
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ function SunburstChart({
2727
const hoverHandler = useRef(onHover)
2828

2929
// this state stores the root node of the sunburst chart
30-
const [root] = useState(
30+
const [root] = useState(() =>
3131
Sentry.startSpan({ name: 'SunburstChart.createRoot' }, () => {
3232
// go through the data and add `value` to each node
3333
const stack = [data]
@@ -75,24 +75,24 @@ function SunburstChart({
7575
const radius = width / 6
7676

7777
// Creates a function for creating arcs representing files and folders.
78-
const drawArc = Sentry.startSpan({ name: 'SunburstChart.drawArc' }, () =>
79-
arc()
78+
const drawArc = Sentry.startSpan({ name: 'SunburstChart.drawArc' }, () => {
79+
return arc()
8080
.startAngle((d) => d.x0)
8181
.endAngle((d) => d.x1)
8282
.padAngle((d) => Math.min((d.x1 - d.x0) / 2, 0.005))
8383
.padRadius(radius * 1.5)
8484
.innerRadius((d) => d.y0 * radius)
8585
.outerRadius((d) => Math.max(d.y0 * radius, d.y1 * radius - 1))
86-
)
86+
})
8787

8888
// A color function you can pass a number from 0-100 to and get a color back from the specified color range
8989
// Ex color(10.4)
90-
const color = Sentry.startSpan({ name: 'SunburstChart.color' }, () =>
91-
scaleSequential()
90+
const color = Sentry.startSpan({ name: 'SunburstChart.color' }, () => {
91+
return scaleSequential()
9292
.domain([colorDomainMin, colorDomainMax])
9393
.interpolator(colorRange)
9494
.clamp(true)
95-
)
95+
})
9696

9797
// Tracks previous location for rendering .. in the breadcrumb.
9898
let previous
@@ -248,7 +248,7 @@ function SunburstChart({
248248
parent.datum(selected)
249249

250250
// Handle animating in/out of a folder
251-
Sentry.startSpan({ name: 'SunburstChart.calculateCoordinates' }, () =>
251+
Sentry.startSpan({ name: 'SunburstChart.calculateCoordinates' }, () => {
252252
root.each((d) => {
253253
// determine x0 and y0
254254
const x0Min = Math.min(
@@ -268,12 +268,12 @@ function SunburstChart({
268268

269269
d.target = { x0, y0, x1, y1 }
270270
})
271-
)
271+
})
272272

273273
// Transition the data on all arcs, even the ones that aren’t visible,
274274
// so that if this transition is interrupted, entering arcs will start
275275
// the next transition from the desired position.
276-
Sentry.startSpan({ name: 'SunburstChart.transitionArcs' }, () =>
276+
Sentry.startSpan({ name: 'SunburstChart.transitionArcs' }, () => {
277277
path
278278
.transition(transition)
279279
.tween('data', (d) => {
@@ -290,7 +290,7 @@ function SunburstChart({
290290
arcVisible(d.target) ? 'auto' : 'none'
291291
)
292292
.attrTween('d', (d) => () => drawArc(d.current))
293-
)
293+
})
294294
})
295295

296296
function handleTextUpdate({ current, selected, transition }) {

0 commit comments

Comments
 (0)