import React, { forwardRef } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { useTheme } from '../Theme'; import BaseInput from './BaseInput'; import { InputInstance, TextAreaProps } from './interface'; import createStyles from './styles/textarea.style'; import { useControllableValue } from 'ahooks'; const TextArea = forwardRef((props, ref) => { const { showCount = false, maxLength, rows = 2, inputStyle, style } = props; const [value, setValue] = useControllableValue(props); const token = useTheme(); const styles = createStyles(token); const renderWordLimit = () => { const count = (value ? `${value}` : '').length; if (maxLength) return `${count}/${maxLength}`; return null; }; return ( {!!showCount && {renderWordLimit()}} ); }); export default TextArea;