React-Native在TextInput中调整表情符号的大小和文本大小

我想在TextInput中使用表情符号调整文本大小,只有文本能很好地工作,但插入表情符号时不行。

const input = useRef(null);

// resize Input func
const onFontSizeChange = () => {
    input.current.setNativeProps({
      style: {
        fontSize: 20,lineHeight: 23,},});
}

<TextInput 
    ref={input}
    multiline={true} 
    style={{fontSize: 16}}
    forceStrutHeight={true}  
    value={textvalue}
    onChangeText={typedText => {
        validate(typedText);
    }}
/>

我该怎么做?

fcliuhongpeng 回答:React-Native在TextInput中调整表情符号的大小和文本大小

只需使用状态对象作为样式,并在单击按钮时更改样式对象即可。

const [style,setStyle] = useState({ fontSize: 16})

const onButtonClick = () => {
    setStyle({ fontSize: 20,lineHeight: 23 })
}

<TextInput 
    multiline={true} 
    style={style}
    forceStrutHeight={true}  
    value={textValue}
    onChangeText={typedText => {
        validate(typedText);
    }}
/>
本文链接:https://www.f2er.com/3080070.html

大家都在问