diff --git a/packages/visx-text/src/Text.tsx b/packages/visx-text/src/Text.tsx index 23f6c5a60..a3683a8c0 100644 --- a/packages/visx-text/src/Text.tsx +++ b/packages/visx-text/src/Text.tsx @@ -115,10 +115,8 @@ class Text extends React.Component { // Only perform calculations if using features that require them (multiline, scaleToFit) if (props.width || props.scaleToFit) { if (needCalculate) { - const words: string[] = (props.children !== null && props.children !== undefined) - ? props.children.toString().split(/(?:(?!\u00A0+)\s+)/) - : []; - + const words: string[] = + props.children == null ? [] : props.children.toString().split(/(?:(?!\u00A0+)\s+)/); this.wordsWithWidth = words.map(word => ({ word, width: getStringWidth(word, props.style) || 0, @@ -138,7 +136,8 @@ class Text extends React.Component { } updateWordsWithoutCalculate(props: TextProps) { - const words = (props.children !== null && props.children !== undefined) ? props.children.toString().split(/(?:(?!\u00A0+)\s+)/) : []; + const words = + props.children == null ? [] : props.children.toString().split(/(?:(?!\u00A0+)\s+)/); this.setState({ wordsByLines: [{ words }] }); }