MCPcopy Create free account
hub / github.com/callstack/react-native-paper / HelperText

Function HelperText

src/components/HelperText/HelperText.tsx:81–156  ·  view source on GitHub ↗
({
  style,
  type = 'info',
  visible = true,
  theme: themeOverrides,
  onLayout,
  padding = 'normal',
  disabled,
  ...rest
}: Props)

Source from the content-addressed store, hash-verified

79 * ```
80 */
81const HelperText = ({
82 style,
83 type = 'info',
84 visible = true,
85 theme: themeOverrides,
86 onLayout,
87 padding = 'normal',
88 disabled,
89 ...rest
90}: Props) => {
91 const theme = useInternalTheme(themeOverrides);
92 const { current: shown } = React.useRef<Animated.Value>(
93 new Animated.Value(visible ? 1 : 0)
94 );
95
96 let { current: textHeight } = React.useRef<number>(0);
97
98 const { scale } = theme.animation;
99
100 const { maxFontSizeMultiplier = 1.5 } = rest;
101
102 React.useEffect(() => {
103 if (visible) {
104 // show text
105 Animated.timing(shown, {
106 toValue: 1,
107 duration: 150 * scale,
108 useNativeDriver: true,
109 }).start();
110 } else {
111 // hide text
112 Animated.timing(shown, {
113 toValue: 0,
114 duration: 180 * scale,
115 useNativeDriver: true,
116 }).start();
117 }
118 }, [visible, scale, shown]);
119
120 const handleTextLayout = (e: LayoutChangeEvent) => {
121 onLayout?.(e);
122 textHeight = e.nativeEvent.layout.height;
123 };
124
125 const textColor = getTextColor({ theme, disabled, type });
126
127 return (
128 <AnimatedText
129 onLayout={handleTextLayout}
130 style={[
131 styles.text,
132 padding !== 'none' ? styles.padding : {},
133 {
134 color: textColor,
135 opacity: shown,
136 transform:
137 visible && type === 'error'
138 ? [

Callers

nothing calls this directly

Calls 2

useInternalThemeFunction · 0.90
getTextColorFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…