Skip to content

Commit c92d914

Browse files
committed
log once
1 parent 5de25c2 commit c92d914

4 files changed

Lines changed: 22 additions & 17 deletions

File tree

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartCartesian.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {CartesianChart} from 'victory-native';
3-
import {CHART_TYPE} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/constants';
43
import {useVictoryChartContext} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/context/VictoryChartContext';
54
import {VictoryChartRenderArgsProvider} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/context/VictoryChartRenderArgsContext';
65
import getYKey from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/utils/getYKey';
@@ -15,11 +14,7 @@ import VictoryChartSeries from './VictoryChartSeries';
1514
* Labels and legend overlays are handled internally via `renderOutside`.
1615
*/
1716
function VictoryChartCartesian() {
18-
const {data, xKey, yKeys, xAxis, yAxis, tnode, labelItems, legendItems, type} = useVictoryChartContext();
19-
20-
if (type !== CHART_TYPE.CARTESIAN) {
21-
return null;
22-
}
17+
const {data, xKey, yKeys, xAxis, yAxis, tnode, labelItems, legendItems} = useVictoryChartContext();
2318

2419
return (
2520
<CartesianChart

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartContent.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
import React from 'react';
1+
import React, {useEffect} from 'react';
22
import {CHART_TYPE} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/constants';
33
import {useVictoryChartContext} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/context/VictoryChartContext';
4+
import Log from '@libs/Log';
45
import VictoryChartCartesian from './VictoryChartCartesian';
56
import VictoryChartPolar from './VictoryChartPolar';
67

78
function VictoryChartContent() {
89
const {type} = useVictoryChartContext();
910

11+
useEffect(() => {
12+
if (type) {
13+
return;
14+
}
15+
Log.warn('Trying to render an invalid chart (empty or mixed chart types).');
16+
}, [type]);
17+
1018
switch (type) {
1119
case CHART_TYPE.CARTESIAN:
1220
return <VictoryChartCartesian />;

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartPolar.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
import {CHART_TYPE} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/constants';
2-
import {useVictoryChartContext} from '@components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/context/VictoryChartContext';
1+
import {useEffect} from 'react';
32
import Log from '@libs/Log';
43

54
/**
65
* Renders the PolarChart with data drawn from context.
76
*/
87
function VictoryChartPolar() {
9-
const {type} = useVictoryChartContext();
10-
11-
if (type !== CHART_TYPE.POLAR) {
12-
return null;
13-
}
8+
useEffect(() => Log.warn('Trying to render unsupported polar charts'), []);
149

1510
// Support for polar chars will be added in a follow up https://github.com/Expensify/App/issues/90546
16-
Log.warn('Trying to render unsupported polar charts');
1711
return null;
1812
}
1913

src/components/HTMLEngineProvider/HTMLRenderers/VictoryChartRenderer/components/VictoryChartSeries.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, {useEffect} from 'react';
22
import type {TNode} from 'react-native-render-html';
33
import Log from '@libs/Log';
44
import VictoryChartBar from './VictoryChartBar';
@@ -19,10 +19,18 @@ const SERIES_RENDERERS: Partial<Record<string, SeriesComponent>> = {
1919

2020
function VictoryChartSeries({tnode}: VictoryChartSeriesProps) {
2121
const SeriesRenderer = SERIES_RENDERERS[tnode.tagName ?? ''];
22-
if (!SeriesRenderer) {
22+
23+
useEffect(() => {
24+
if (SeriesRenderer) {
25+
return;
26+
}
2327
Log.warn('Trying to render an unsupported series chart', {tagName: tnode.tagName});
28+
}, [SeriesRenderer, tnode.tagName]);
29+
30+
if (!SeriesRenderer) {
2431
return null;
2532
}
33+
2634
return <SeriesRenderer tnode={tnode} />;
2735
}
2836

0 commit comments

Comments
 (0)