import React, { useState } from 'react';
/**
* 问题:textarea的value值为null或者不赋值时,placeholder动态设置值后,输入框显undefined
* 复现步骤:
* 1. textarea组件value初始值为null或者不赋值时
* 2. 点击按钮设置placeholder值
* 3. 输入框显undefined
* 渠道:只有支付宝小程序复现
*/
const TextareaBug1 = (props) => {
const [placeholderText, setPlaceholderText] = useState('');
const [valuText, setValuText] = useState(null); // 或者useState()
const styleObj = {
background: 'rgb(91, 201, 192)',
border: '1px #efefef solid',
padding: '20px',
marginBottom: '20px'
}
return (
<>
<view style={styleObj} onTap={() => setPlaceholderText('初始值')}>初始值</view>
<view style={styleObj} onTap={() => setPlaceholderText('值111')}>值111</view>
<textarea placeholder={placeholderText} value={valuText}/>
</>
);
};
export default TextareaBug1;