diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 97ce10d0a2099d..52b063d5bc4b4c 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -18,6 +18,7 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent'; import {type TextProps} from './TextProps'; import * as React from 'react'; import {useContext, useMemo, useState} from 'react'; +import invariant from 'invariant'; /** * Text is the fundamental component for displaying text. @@ -148,6 +149,15 @@ const Text: React.AbstractComponent< } } + const numberOfLines = restProps.numberOfLines; + if (numberOfLines != null) { + invariant( + numberOfLines >= 0, + 'Number of lines in component can not be negative, passed value: %s.', + [numberOfLines], + ); + } + const hasTextAncestor = useContext(TextAncestor); return hasTextAncestor ? (