Skip to content

Commit 1155ef1

Browse files
committed
fix undefined error
1 parent 53793f4 commit 1155ef1

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

packages/victory-pie/src/curved-label.tsx

+11-9
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ export interface CurvedLabelProps
4242
textPathComponent?: React.ReactElement;
4343
}
4444

45+
const defaultProps = {
46+
tspanComponent: <TSpan />,
47+
capHeight: 0.71, // Magic number from d3.
48+
lineHeight: 1,
49+
textComponent: <Text />,
50+
textPathComponent: <TextPath />,
51+
};
52+
4553
const defaultStyles = VictoryLabel.defaultStyles;
4654

4755
const getFontSize = (style) => {
@@ -171,7 +179,9 @@ const renderLabel = (calculatedProps, tspanValues) => {
171179
style: currentStyle,
172180
children: line,
173181
};
174-
return React.cloneElement(tspanComponent, tspanProps);
182+
if(tspanComponent){
183+
return React.cloneElement(tspanComponent, tspanProps)
184+
}
175185
});
176186

177187
const textPathProps = {
@@ -190,14 +200,6 @@ const renderLabel = (calculatedProps, tspanValues) => {
190200
return React.cloneElement(textComponent, textProps, tspans);
191201
};
192202

193-
const defaultProps = {
194-
tspanComponent: <TSpan />,
195-
capHeight: 0.71, // Magic number from d3.
196-
lineHeight: 1,
197-
textComponent: <Text />,
198-
textPathComponent: <TextPath />,
199-
};
200-
201203
export const CurvedLabel: {
202204
role: string;
203205
defaultStyles: typeof defaultStyles;

0 commit comments

Comments
 (0)