Skip to content

Commit 9747ca3

Browse files
committed
refactor: initialize series snapshot from reaction
1 parent 8561d55 commit 9747ca3

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

‎packages/react-native-livechart/src/components/LiveChartSeries.tsx‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Canvas, Group, Rect, type SkFont } from "@shopify/react-native-skia";
88
import {
99
forwardRef,
1010
useImperativeHandle,
11-
useLayoutEffect,
1211
useState,
1312
} from "react";
1413
import { StyleSheet, View } from "react-native";
@@ -474,18 +473,9 @@ function useLiveChartSeriesController(props: LiveChartSeriesProps) {
474473
);
475474

476475
// Snapshot of the series config (colors, styles, labels) for layout + line
477-
// rendering. Seeded off the render path below and refreshed by the reaction
478-
// further down — reading the `series` SharedValue during render trips
479-
// Reanimated's strict-mode warning. React flushes layout-effect state before
480-
// paint, so the seed causes no flash.
476+
// rendering. The animated reaction below emits the initial snapshot and every
477+
// subsequent configuration change without reading the SharedValue in render.
481478
const [seriesSnapshot, setSeriesSnapshot] = useState<SeriesConfig[]>([]);
482-
useLayoutEffect(() => {
483-
// `.get()` (not `.value`): React Compiler hoists the `.value` getter read into
484-
// render scope for memoization, which trips Reanimated's strict-mode warning;
485-
// it leaves the `.get()` method call inside the effect.
486-
// eslint-disable-next-line react-hooks/set-state-in-effect -- Reanimated: seed from the SharedValue outside render to avoid strict-mode access warnings
487-
setSeriesSnapshot(series.get().slice());
488-
}, [series]);
489479

490480
// Mount per-series drawing worklets only for real series. The previous fixed
491481
// 12-slot render kept 144 derived-value mappers alive for the default stroke,

0 commit comments

Comments
 (0)